Skip to content

Commit

Permalink
MB-24309: Rip out Greenstack code [2/n]
Browse files Browse the repository at this point in the history
This patch rips our the remaining definitions used from
libgreenstack and moves them to mcbp and internal to
the test library. Further refactor should be performed
to clean up all of the usage.

Change-Id: I25a9e20194b5b74ba06f9ed04c9396cddb886225
Reviewed-on: http://review.couchbase.org/77997
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
  • Loading branch information
trondn committed May 11, 2017
1 parent bfd35cf commit 0b86987
Show file tree
Hide file tree
Showing 26 changed files with 247 additions and 508 deletions.
23 changes: 0 additions & 23 deletions include/libgreenstack/Greenstack.h

This file was deleted.

38 changes: 0 additions & 38 deletions include/libgreenstack/memcached/Bucket.h

This file was deleted.

39 changes: 0 additions & 39 deletions include/libgreenstack/memcached/Cas.h

This file was deleted.

35 changes: 0 additions & 35 deletions include/libgreenstack/memcached/Compression.h

This file was deleted.

35 changes: 0 additions & 35 deletions include/libgreenstack/memcached/Datatype.h

This file was deleted.

39 changes: 0 additions & 39 deletions include/libgreenstack/memcached/Mutation.h

This file was deleted.

26 changes: 21 additions & 5 deletions include/memcached/protocol_binary.h
Expand Up @@ -546,11 +546,16 @@ typedef enum {
* See section 3.4 Data Types
*/

typedef uint8_t protocol_binary_datatype_t;
#define PROTOCOL_BINARY_RAW_BYTES uint8_t(0)
#define PROTOCOL_BINARY_DATATYPE_JSON uint8_t(1)
#define PROTOCOL_BINARY_DATATYPE_SNAPPY uint8_t(2)
#define PROTOCOL_BINARY_DATATYPE_XATTR uint8_t(4)
namespace mcbp {
typedef uint8_t datatype_t;
enum class Datatype : datatype_t { Raw = 0, Json = 1, Snappy = 2, Xattr = 4 };
} // namespace mcbp

typedef mcbp::datatype_t protocol_binary_datatype_t;
#define PROTOCOL_BINARY_RAW_BYTES mcbp::datatype_t(mcbp::Datatype::Raw)
#define PROTOCOL_BINARY_DATATYPE_JSON mcbp::datatype_t(mcbp::Datatype::Json)
#define PROTOCOL_BINARY_DATATYPE_SNAPPY mcbp::datatype_t(mcbp::Datatype::Snappy)
#define PROTOCOL_BINARY_DATATYPE_XATTR mcbp::datatype_t(mcbp::Datatype::Xattr)

/*
* Bitmask that defines the datatypes that can be resident in memory. For
Expand Down Expand Up @@ -2557,3 +2562,14 @@ inline std::string to_string(const protocol_binary_datatype_t datatype) {
}
} // namespace datatype
} // namespace mcbp

namespace mcbp {
typedef uint64_t cas_t;

namespace cas {
/**
* The special value used as a wildcard and match all CAS values
*/
const cas_t Wildcard = 0x0;
} // namespace cas
} // namespace mcbp
1 change: 0 additions & 1 deletion protocol/connection/client_connection.cc
Expand Up @@ -20,7 +20,6 @@
#include "cJSON_utils.h"

#include <cbsasl/cbsasl.h>
#include <libgreenstack/Greenstack.h>
#include <memcached/protocol_binary.h>
#include <platform/dirutils.h>
#include <platform/strerror.h>
Expand Down
38 changes: 27 additions & 11 deletions protocol/connection/client_connection.h
Expand Up @@ -23,7 +23,6 @@
#include <cstdlib>
#include <daemon/settings.h>
#include <engines/ewouldblock_engine/ewouldblock_engine.h>
#include <libgreenstack/Greenstack.h>
#include <memcached/openssl.h>
#include <memcached/protocol_binary.h>
#include <memcached/types.h>
Expand Down Expand Up @@ -56,9 +55,8 @@ class DocumentInfo {
std::string id;
uint32_t flags;
std::string expiration;
Greenstack::Compression compression;
Greenstack::Datatype datatype;
uint64_t cas;
mcbp::Datatype datatype;
mcbp::cas_t cas;
};

class Document {
Expand All @@ -75,6 +73,22 @@ class MutationInfo {
uint64_t vbucketuuid;
};

enum class BucketType : uint8_t {
Invalid = 0,
Memcached = 1,
Couchbase = 2,
EWouldBlock = 3
};

typedef uint8_t mutation_type_t;
namespace MutationType {
const mutation_type_t Add = 0;
const mutation_type_t Set = 1;
const mutation_type_t Replace = 2;
const mutation_type_t Append = 3;
const mutation_type_t Prepend = 4;
} // namespace MutationType

class ConnectionError : public std::runtime_error {
public:
explicit ConnectionError(const char* what_arg)
Expand Down Expand Up @@ -218,7 +232,7 @@ class MemcachedConnection {
*/
virtual void createBucket(const std::string& name,
const std::string& config,
const Greenstack::BucketType& type) = 0;
const BucketType type) = 0;

/**
* Delete the named bucket
Expand Down Expand Up @@ -290,8 +304,9 @@ class MemcachedConnection {
*/
virtual Frame encodeCmdGet(const std::string& id, uint16_t vbucket) = 0;

MutationInfo mutate(const Document& doc, uint16_t vbucket,
const Greenstack::mutation_type_t type) {
MutationInfo mutate(const Document& doc,
uint16_t vbucket,
const mutation_type_t type) {
return mutate(doc.info,
vbucket,
cb::const_byte_buffer(doc.value.data(), doc.value.size()),
Expand All @@ -309,9 +324,10 @@ class MemcachedConnection {
* @param type the type of mutation to perform
* @return the new cas value for success
*/
virtual MutationInfo mutate(const DocumentInfo& info, uint16_t vbucket,
virtual MutationInfo mutate(const DocumentInfo& info,
uint16_t vbucket,
cb::const_byte_buffer value,
const Greenstack::mutation_type_t type) = 0;
const mutation_type_t type) = 0;

/**
* Convenience method to store (aka "upsert") an item.
Expand All @@ -325,12 +341,12 @@ class MemcachedConnection {
const std::string& id,
uint16_t vbucket,
const T& value,
Greenstack::Datatype datatype = Greenstack::Datatype::Raw) {
mcbp::Datatype datatype = mcbp::Datatype::Raw) {
Document doc{};
doc.value.assign(value.begin(), value.end());
doc.info.id = id;
doc.info.datatype = datatype;
return mutate(doc, vbucket, Greenstack::MutationType::Set);
return mutate(doc, vbucket, MutationType::Set);
}
MutationInfo store(const std::string& id, uint16_t vbucket,
const char *value, size_t len) {
Expand Down

0 comments on commit 0b86987

Please sign in to comment.