#include <libmemcached/watchpoint.h>
#include <libmemcached/is.h>
-#include <libmemcached/instance.h>
+#ifdef __cplusplus
+# include "libmemcached/instance.hpp"
+#endif
#include <libmemcached/server_instance.h>
#ifdef HAVE_POLL_H
{
org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, x);
- if (memcached_instance_response_count(instance) > 0)
+ if (instance->response_count() > 0)
{
(void)memcached_response(instance, NULL, 0, NULL);
}
{
org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, x);
- if (memcached_instance_response_count(instance))
+ if (instance->response_count())
{
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
memcached_io_write(instance);
}
- while(memcached_instance_response_count(instance))
+ while(instance->response_count())
{
(void)memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, &ptr->result);
}
};
- if (memcached_instance_response_count(instance) == 0)
+ if (instance->response_count() == 0)
{
rc= memcached_connect(instance);
{
org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, x);
- if (memcached_instance_response_count(instance))
+ if (instance->response_count())
{
/* We need to do something about non-connnected hosts in the future */
if ((memcached_io_write(instance, "\r\n", 2, true)) == -1)
org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, server_key);
- if (memcached_instance_response_count(instance) == 0)
+ if (instance->response_count() == 0)
{
rc= memcached_connect(instance);
if (memcached_failed(rc))
org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, x);
initialize_binary_request(instance, request.message.header);
- if (memcached_instance_response_count(instance))
+ if (instance->response_count())
{
if (memcached_io_write(instance) == false)
{
org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, server);
- if (memcached_instance_response_count(instance) == 0)
+ if (instance->response_count() == 0)
{
rc= memcached_connect(instance);
noinst_HEADERS+= libmemcached/error.hpp
noinst_HEADERS+= libmemcached/flag.hpp
noinst_HEADERS+= libmemcached/initialize_query.h
-noinst_HEADERS+= libmemcached/instance.h
noinst_HEADERS+= libmemcached/instance.hpp
noinst_HEADERS+= libmemcached/internal.h
noinst_HEADERS+= libmemcached/io.h
void memcached_instance_free(org::libmemcached::Instance* self)
{
- if (self == NULL)
- {
- return;
- }
-
- __instance_free(self);
-}
-
-/*
- If we do not have a valid object to clone from, we toss an error.
-*/
-memcached_server_st *memcached_instance_2_server(org::libmemcached::Instance* source)
-{
- /* We just do a normal create if source is missing */
- if (source == NULL)
+ if (self)
{
- return NULL;
+ __instance_free(self);
}
-
- memcached_string_t hostname= { memcached_string_make_from_cstr(source->hostname) };
- return __server_create_with(source->root, NULL,
- hostname,
- source->port(), source->weight,
- source->type);
-
}
memcached_return_t memcached_server_cursor(const memcached_st *ptr,
return (memcached_server_instance_st)self->last_disconnected_server;
}
-const char *memcached_instance_name(const memcached_server_instance_st self)
-{
- WATCHPOINT_ASSERT(self);
- if (self == NULL)
- return NULL;
-
- return self->hostname;
-}
-
-in_port_t memcached_instance_port(const memcached_server_instance_st self)
-{
- WATCHPOINT_ASSERT(self);
- if (self == NULL)
- {
- return 0;
- }
-
- return self->port();
-}
-
void memcached_instance_next_retry(memcached_server_instance_st self, const time_t absolute_time)
{
WATCHPOINT_ASSERT(self);
((org::libmemcached::Instance*)self)->next_retry= absolute_time;
}
}
-
-uint32_t memcached_instance_response_count(const org::libmemcached::Instance* self)
-{
- WATCHPOINT_ASSERT(self);
- if (self == NULL)
- {
- return 0;
- }
-
- return self->cursor_active_;
-}
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Libmemcached library
- *
- * Copyright (C) 2012 Data Differential, http://datadifferential.com/
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *
- * * The names of its contributors may not be used to endorse or
- * promote products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-
-#pragma once
-
-#ifndef WIN32
-# ifdef HAVE_NETDB_H
-# include <netdb.h>
-# endif
-#endif
-
-#ifdef NI_MAXHOST
-# define MEMCACHED_NI_MAXHOST NI_MAXHOST
-#else
-# define MEMCACHED_NI_MAXHOST 1025
-#endif
-
-#ifdef NI_MAXSERV
-# define MEMCACHED_NI_MAXSERV NI_MAXSERV
-#else
-# define MEMCACHED_NI_MAXSERV 32
-#endif
-
-#ifdef __cplusplus
-
-namespace org {
-namespace libmemcached {
-
-// @todo Complete class transformation
-struct Instance {
- in_port_t port() const
- {
- return port_;
- }
-
- void port(in_port_t arg)
- {
- port_= arg;
- }
-
- void mark_server_as_clean()
- {
- server_failure_counter= 0;
- next_retry= 0;
- }
-
- void disable()
- {
- }
-
- void enable()
- {
- }
-
- uint32_t response_count() const
- {
- return cursor_active_;
- }
-
- struct {
- bool is_allocated:1;
- bool is_initialized:1;
- bool is_shutting_down:1;
- bool is_dead:1;
- } options;
- uint32_t cursor_active_;
- in_port_t port_;
- memcached_socket_t fd;
- uint32_t io_bytes_sent; /* # bytes sent since last read */
- uint32_t request_id;
- uint32_t server_failure_counter;
- uint64_t server_failure_counter_query_id;
- uint32_t weight;
- uint32_t version;
- enum memcached_server_state_t state;
- struct {
- uint32_t read;
- uint32_t write;
- uint32_t timeouts;
- size_t _bytes_read;
- } io_wait_count;
- uint8_t major_version; // Default definition of UINT8_MAX means that it has not been set.
- uint8_t micro_version; // ditto, and note that this is the third, not second version bit
- uint8_t minor_version; // ditto
- memcached_connection_t type;
- char *read_ptr;
- size_t read_buffer_length;
- size_t read_data_length;
- size_t write_buffer_offset;
- struct addrinfo *address_info;
- struct addrinfo *address_info_next;
- time_t next_retry;
- struct memcached_st *root;
- uint64_t limit_maxbytes;
- struct memcached_error_t *error_messages;
- char read_buffer[MEMCACHED_MAX_BUFFER];
- char write_buffer[MEMCACHED_MAX_BUFFER];
- char hostname[MEMCACHED_NI_MAXHOST];
-};
-
-} // namespace libmemcached
-} // namespace org
-
-#endif
#pragma once
+#ifndef WIN32
+# ifdef HAVE_NETDB_H
+# include <netdb.h>
+# endif
+#endif
+
+#ifdef NI_MAXHOST
+# define MEMCACHED_NI_MAXHOST NI_MAXHOST
+#else
+# define MEMCACHED_NI_MAXHOST 1025
+#endif
+
+#ifdef NI_MAXSERV
+# define MEMCACHED_NI_MAXSERV NI_MAXSERV
+#else
+# define MEMCACHED_NI_MAXSERV 32
+#endif
+
+namespace org {
+namespace libmemcached {
+
+// @todo Complete class transformation
+struct Instance {
+ in_port_t port() const
+ {
+ return port_;
+ }
+
+ void port(in_port_t arg)
+ {
+ port_= arg;
+ }
+
+ void mark_server_as_clean()
+ {
+ server_failure_counter= 0;
+ next_retry= 0;
+ }
+
+ void disable()
+ {
+ }
+
+ void enable()
+ {
+ }
+
+ uint32_t response_count() const
+ {
+ return cursor_active_;
+ }
+
+ struct {
+ bool is_allocated:1;
+ bool is_initialized:1;
+ bool is_shutting_down:1;
+ bool is_dead:1;
+ } options;
+ uint32_t cursor_active_;
+ in_port_t port_;
+ memcached_socket_t fd;
+ uint32_t io_bytes_sent; /* # bytes sent since last read */
+ uint32_t request_id;
+ uint32_t server_failure_counter;
+ uint64_t server_failure_counter_query_id;
+ uint32_t weight;
+ uint32_t version;
+ enum memcached_server_state_t state;
+ struct {
+ uint32_t read;
+ uint32_t write;
+ uint32_t timeouts;
+ size_t _bytes_read;
+ } io_wait_count;
+ uint8_t major_version; // Default definition of UINT8_MAX means that it has not been set.
+ uint8_t micro_version; // ditto, and note that this is the third, not second version bit
+ uint8_t minor_version; // ditto
+ memcached_connection_t type;
+ char *read_ptr;
+ size_t read_buffer_length;
+ size_t read_data_length;
+ size_t write_buffer_offset;
+ struct addrinfo *address_info;
+ struct addrinfo *address_info_next;
+ time_t next_retry;
+ struct memcached_st *root;
+ uint64_t limit_maxbytes;
+ struct memcached_error_t *error_messages;
+ char read_buffer[MEMCACHED_MAX_BUFFER];
+ char write_buffer[MEMCACHED_MAX_BUFFER];
+ char hostname[MEMCACHED_NI_MAXHOST];
+};
+
+} // namespace libmemcached
+} // namespace org
+
org::libmemcached::Instance* __instance_create_with(memcached_st *memc,
org::libmemcached::Instance* self,
const memcached_string_t& hostname,
uint32_t weight,
const memcached_connection_t type);
-const char *memcached_instance_name(const org::libmemcached::Instance* self);
-
-in_port_t memcached_instance_port(const org::libmemcached::Instance* self);
-
memcached_return_t memcached_instance_push(memcached_st *ptr, const org::libmemcached::Instance*, uint32_t);
-memcached_server_st *memcached_instance_2_server(org::libmemcached::Instance* source);
-
-uint32_t memcached_instance_response_count(const org::libmemcached::Instance* self);
-
void __instance_free(org::libmemcached::Instance *);
return instance;
}
- if (memcached_instance_response_count(instance) > 0)
+ if (instance->response_count() > 0)
{
fds[host_index].events= POLLIN;
fds[host_index].revents= 0;
{
org::libmemcached::Instance* instance= memcached_instance_fetch(memc, x);
- if (memcached_instance_response_count(instance) > 0)
+ if (instance->response_count() > 0)
{
return instance;
}
return TEST_SUCCESS;
}
-#include "libmemcached/instance.h"
+#include "libmemcached/instance.hpp"
static test_return_t cull_TEST(memcached_st *memc)
{
uint32_t count= memcached_server_count(memc);
#include <tests/debug.h>
#include <tests/print.h>
-#include "libmemcached/instance.h"
+#include "libmemcached/instance.hpp"
/* Dump each server's keys */
static memcached_return_t print_keys_callback(const memcached_st *,
#include "libmemcached/server_instance.h"
#include "libmemcached/continuum.hpp"
-#include "libmemcached/instance.h"
+#include "libmemcached/instance.hpp"
#include <tests/ketama.h>
#include <tests/ketama_test_cases.h>
#include "tests/keys.hpp"
-#include "libmemcached/instance.h"
+#include "libmemcached/instance.hpp"
static memcached_st * create_single_instance_memcached(const memcached_st *original_memc, const char *options)
{
#include <tests/libmemcached-1.0/parser.h>
#include <tests/print.h>
-#include "libmemcached/instance.h"
+#include "libmemcached/instance.hpp"
enum scanner_type_t
{
#include <pthread.h>
#include <poll.h>
-#include "libmemcached/instance.h"
+#include "libmemcached/instance.hpp"
#ifndef __INTEL_COMPILER
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
return TEST_SUCCESS;
}
-#include "libmemcached/instance.h"
+#include "libmemcached/instance.hpp"
test_return_t replication_get_test(memcached_st *memc)
{
#include <libtest/server.h>
-#include "libmemcached/instance.h"
+#include "libmemcached/instance.hpp"
#ifndef __INTEL_COMPILER
#pragma GCC diagnostic ignored "-Wstrict-aliasing"