Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
9615bb79
Commit
9615bb79
authored
Feb 06, 2015
by
Axel Auweter
Browse files
Reimplement insert() in CQL. Closes ticket
#21
.
parent
1d08ad02
Changes
10
Hide whitespace changes
Inline
Side-by-side
CollectAgent/collectagent.cpp
View file @
9615bb79
...
...
@@ -79,11 +79,10 @@ void mqttCallback(SimpleMQTTMessage *msg)
* the record in the database.
*/
SensorId
sid
;
mySensorDataStore
->
topicToSid
(
&
sid
,
msg
->
getTopic
());
if
(
mySensorDataStore
->
topicToSid
(
&
sid
,
msg
->
getTopic
()))
{
#if 0
cout << "Topic decode successful:"
<< "\nRaw: " <<
sid.raw[0] << " "
<< sid.raw[1]
<< "\nRaw: " <<
hex << setw(16) << setfill('0') << sid.raw[0] << " " << hex << setw(16) << setfill('0')
<< sid.raw[1]
<< "\ndatacenter_id: " << hex << ((sid.dl & 0xFF00000000000000) >> 56)
<< "\ncluster_id: " << hex << ((sid.dl & 0x00FF000000000000) >> 48)
<< "\nrack_id: " << hex << ((sid.dl & 0x0000FFFF00000000) >> 32)
...
...
@@ -96,10 +95,13 @@ void mqttCallback(SimpleMQTTMessage *msg)
<< "\nsensor_number: " << hex << sid.dsid.sensor_number
<< "\n";
#endif
//mySensorDataStore->insert(&sid, ts, *((uint64_t*)msg->getPayload()));
mySensorDataStore
->
insert
(
&
sid
,
ts
,
val
);
}
#if 0
else {
cout << "Wrong topic format: " << msg->getTopic() << "\n";
}
#endif
}
delete
msg
;
}
...
...
DCDBLib/Makefile
View file @
9615bb79
...
...
@@ -8,7 +8,6 @@ CXXFLAGS = -O0 -g -Wall -Werror -Wno-unused-local-typedefs -Wno-unknown-warning-
# List of object files to build and the derived list of corresponding source files
OBJS
=
src/sensordatastore.o
\
src/cassandraBackend.o
SRC
=
$(
patsubst
cassandra/%,,
$(OBJS:.o=.cpp)
)
# List of public header files necessary to use this libray
PUBHEADERS
=
$(
shell
find include
-type
f
-iname
"*.h"
)
...
...
@@ -36,8 +35,7 @@ P = $(shell cd $(DCDBDEPLOYPATH)/lib/ && pwd)
.PHONY
:
check-target-env all clean install
# Main Library Target
$(TARGET)
:
$(SRC)
$(MAKE)
$(OBJS)
$(TARGET)
:
$(OBJS)
@
if
[
"
$(OS)
"
=
"Darwin"
]
;
then
\
echo
"Linking library in Mac OS style:
$(TARGET)
"
;
\
$(CXX)
$(CXXFLAGS)
$(DLFLAGS)
-o
$(TARGET)
$(OBJS)
$(LIBS)
;
\
...
...
@@ -46,7 +44,7 @@ $(TARGET): $(SRC)
$(CXX)
$(CXXFLAGS)
$(DLFLAGS)
-o
$(TARGET)
$(OBJS)
$(LIBS)
;
\
fi
all
:
$(TARGET)
all
:
$(TARGET)
check-target-env
# Alert the user to put the necessary paths into LD_LIBRARY_PATH (or similar on other platforms)
check-target-env
:
...
...
DCDBLib/include_internal/cassandraBackend.h
View file @
9615bb79
...
...
@@ -70,7 +70,7 @@ public:
/**
* @brief Starts a connection to a Cassandra front-end node.
* @param hostname The hostname to connect to.
* @param port The TCP port number on which Cassandra is listening for
Thrift
clients.
* @param port The TCP port number on which Cassandra is listening for
CQL
clients.
* @return Returns true if a connection was established, false otherwise.
*/
bool
connect
(
std
::
string
hostname
,
int
port
);
...
...
@@ -129,12 +129,11 @@ public:
/**
* @brief Insert a data into the database
* @param columnFamily The name of the column family
* @param key The name of the row key
* @param ts The data time stamp (used for column name and time information in Cassandra
* @param value The data itself
*/
void
insert
(
std
::
string
columnFamily
,
std
::
string
key
,
uint64_t
ts
,
uint64_t
value
);
void
insert
(
std
::
string
key
,
uint64_t
ts
,
uint64_t
value
);
/* Class constructor / desctructor */
...
...
DCDBLib/src/cassandraBackend.cpp
View file @
9615bb79
...
...
@@ -64,8 +64,6 @@ bool CassandraBackend::connect(std::string hostname, int port)
if
(
!
session
)
session
=
cass_session_new
();
printf
(
"Allocated cluster object: %p
\n
"
,
cluster
);
/* Set hostname and port */
cass_cluster_set_contact_points
(
cluster
,
hostname
.
c_str
());
cass_cluster_set_port
(
cluster
,
port
);
...
...
@@ -75,16 +73,12 @@ bool CassandraBackend::connect(std::string hostname, int port)
/* Connect to the server */
CassError
rc
=
CASS_OK
;
printf
(
"Connecting session...
\n
"
);
CassFuture
*
future
=
cass_session_connect
(
session
,
cluster
);
printf
(
"Waiting for connection...
\n
"
);
/* Wait for successful connection */
cass_future_wait
(
future
);
printf
(
"Checking for error code...
\n
"
);
rc
=
cass_future_error_code
(
future
);
printf
(
"Error code: %d
\n
"
,
rc
);
if
(
rc
!=
CASS_OK
)
{
printError
(
future
);
cass_future_free
(
future
);
...
...
@@ -250,58 +244,53 @@ std::string CassandraBackend::int64Convert(uint64_t n)
/**
* @details
* Since Cassandra uses
manly
strings to communicate in
Thrift,
*
this
function converts the ts and value parameters to big-endian
* Since Cassandra uses strings to communicate in
CQL, this
* function converts the ts and value parameters to big-endian
* byte arrays using the int64convert function.
*
* FIXME: Do performance optimizations, e.g. the prepared
* statement should not be created on every insert
*/
void
CassandraBackend
::
insert
(
std
::
string
columnFamily
,
std
::
string
key
,
uint64_t
ts
,
uint64_t
value
)
void
CassandraBackend
::
insert
(
std
::
string
key
,
uint64_t
ts
,
uint64_t
value
)
{
#if 0
try {
ColumnParent cparent;
Column c;
std::string name, cvalue;
cparent.column_family = columnFamily;
/*
* Convert to Cassandra formats and assign
* Cassandra-internal timestamp.
*/
name = int64Convert(ts);
cvalue = int64Convert(value);
c.name = name;
c.value = cvalue;
c.__isset.value = true;
c.timestamp = ts/1000;
c.__isset.timestamp = true;
/*
* Call Hector to do the insert.
*/
myClient->insert(key, cparent, c, ConsistencyLevel::ONE);
}
/*
* TODO: All caught exceptions should be handled more gracefully
* as we would like to keep the CollectAgent running as long as
* possible.
*/
catch(const TTransportException& te){
std::cout << "TP Exception: " << te.what() << "[" << te.getType() << "]\n";
exit(EXIT_FAILURE);
}
catch(const InvalidRequestException& ire){
std::cout << "IRE Exception: " << ire.what() << "[" << ire.why << "]\n";
exit(EXIT_FAILURE);
std::cout << "Inserting@CassandraBackend ( <<KEY>>" << ", " << ts << ", " << value << ")" << std::endl;
#endif
CassError
rc
=
CASS_OK
;
CassStatement
*
statement
=
NULL
;
CassFuture
*
future
=
NULL
;
const
CassPrepared
*
prepared
=
NULL
;
CassString
query
=
cass_string_init
(
"INSERT INTO dcdb.sensordata (sid, ts, value) VALUES (?, ?, ?);"
);
future
=
cass_session_prepare
(
session
,
query
);
cass_future_wait
(
future
);
rc
=
cass_future_error_code
(
future
);
if
(
rc
!=
CASS_OK
)
{
printError
(
future
);
}
else
{
prepared
=
cass_future_get_prepared
(
future
);
}
catch(const NotFoundException& nfe){
std::cout << "NF Exception: " << nfe.what() << "\n";
exit(EXIT_FAILURE);
statement
=
cass_prepared_bind
(
prepared
);
CassBytes
sid
=
cass_bytes_init
((
cass_byte_t
*
)(
key
.
c_str
()),
16
);
cass_statement_bind_bytes_by_name
(
statement
,
"sid"
,
sid
);
cass_statement_bind_int64_by_name
(
statement
,
"ts"
,
ts
);
cass_statement_bind_int64_by_name
(
statement
,
"value"
,
value
);
future
=
cass_session_execute
(
session
,
statement
);
cass_future_wait
(
future
);
rc
=
cass_future_error_code
(
future
);
if
(
rc
!=
CASS_OK
)
{
printError
(
future
);
}
#else
std
::
cerr
<<
"Insert currently unimplemented!
\n
"
;
#endif
cass_future_free
(
future
)
;
cass_statement_free
(
statement
);
}
CassandraBackend
::
CassandraBackend
()
...
...
DCDBLib/src/sensordatastore.cpp
View file @
9615bb79
...
...
@@ -24,7 +24,7 @@
* CassandraBackend class (to easy switching to other
* key-value style databases in the future).
*
* To use the library in your client application, sim
n
ply
* To use the library in your client application, simply
* include the sensordatastore.h header file and initialize
* an object of the SensorDataStore class.
*/
...
...
@@ -104,7 +104,9 @@ void SensorDataStoreImpl::init(std::string hostname, int port) {
* Open the connection to the Cassandra database and
* create the necessary keyspaces and column families.
*/
csBackend
->
connect
(
hostname
,
port
);
if
(
!
csBackend
->
connect
(
hostname
,
port
))
{
exit
(
EXIT_FAILURE
);
}
/* Keyspace and column family for sensor aliases */
/* FIXME: We should have a good way to determine the number of replicas here */
...
...
@@ -166,12 +168,16 @@ void SensorDataStoreImpl::init(std::string hostname, int port) {
*/
void
SensorDataStoreImpl
::
insert
(
SensorId
*
sid
,
uint64_t
ts
,
uint64_t
value
)
{
#if 0
std::cout << "Inserting@SensorDataStoreImpl (" << sid->raw[0] << " " << sid->raw[1] << ", " << ts << ", " << value << ")" << std::endl;
#endif
/* Calculate and insert week number */
uint16_t
week
=
ts
/
604800000000
;
sid
->
dsid
.
rsvd
=
week
;
/* Insert into Cassandra */
csBackend
->
insert
(
CF_SENSORDATA
,
sidConvert
(
sid
),
ts
,
value
);
csBackend
->
insert
(
sidConvert
(
sid
),
ts
,
value
);
}
/**
...
...
@@ -228,7 +234,6 @@ bool SensorDataStore::topicToSid(SensorId* sid, std::string topic)
* class.
*/
void
SensorDataStore
::
insert
(
SensorId
*
sid
,
uint64_t
ts
,
uint64_t
value
)
//template <typename T> void SensorDataStore::insert(T* sid, uint64_t ts, uint64_t value)
{
impl
->
insert
(
sid
,
ts
,
value
);
}
...
...
DCDBTools/dcdbconfig/Makefile
View file @
9615bb79
...
...
@@ -3,7 +3,6 @@ include ../../config.mk
CXXFLAGS
=
-O0
-g
--std
=
c++11
-Wall
-Wno-unused-local-typedefs
-Wno-unknown-warning-option
-fmessage-length
=
0
-I
$(DCDBDEPLOYPATH)
/include/
-I
$(DCDBBASEPATH)
/include/
OBJS
=
dcdbconfig.o sensoraction.o useraction.o casshelper.o
LIBS
=
-L
$(DCDBDEPLOYPATH)
/lib/
-ldcdb
-lcassandra
-lboost_random
-lboost_system
-luv
#-lpthread -lboost_system -lboost_thread -lthrift
TARGET
=
dcdbconfig
.PHONY
:
clean install
...
...
DCDBTools/dcdbquery/Makefile
View file @
9615bb79
...
...
@@ -3,7 +3,6 @@ include ../../config.mk
CXXFLAGS
=
-O0
-g
--std
=
c++11
-Wall
-Wno-unused-local-typedefs
-Wno-unknown-warning-option
-fmessage-length
=
0
-I
$(DCDBDEPLOYPATH)
/include/
-I
$(DCDBBASEPATH)
/include/
OBJS
=
dcdbquery.o
LIBS
=
-L
$(DCDBDEPLOYPATH)
/lib/
-ldcdb
#-lpthread -lboost_system -lboost_thread -lthrift
TARGET
=
dcdbquery
.PHONY
:
clean install
...
...
Makefile
View file @
9615bb79
...
...
@@ -4,25 +4,21 @@ LIBRARIES = DCDBLib
PROJECTS
=
FilePusher SysFsPusher CollectAgent ParastationProvider IPMIPusher MontBlancPusher SNMPPusher DCDBTools
CASSANDRA_VERSION
=
2.1.2
THRIFT_VERSION
=
0.9.2
MOSQUITTO_VERSION
=
1.3.5
BOOST_VERSION
=
1.57.0
SNMP_VERSION
=
5.7.2.1
OPENSSL_VERSION
=
1.0.1k
LIBEVENT_VERSION
=
2.0.21-stable
CPPDRV_VERSION
=
1.0.0
LIBUV_VERSION
=
0.10.32
BOOST_VERSION_U
=
$(
subst
.,_,
$(BOOST_VERSION)
)
DISTFILES
=
thrift-
$(THRIFT_VERSION)
.tar.gz
;
https://dist.apache.org/repos/dist/release/thrift/
$(THRIFT_VERSION)
/thrift-
$(THRIFT_VERSION)
.tar.gz
\
apache-cassandra-
$(CASSANDRA_VERSION)
.tar.gz
;
http://apache.cs.utah.edu/cassandra/
$(CASSANDRA_VERSION)
/apache-cassandra-
$(CASSANDRA_VERSION)
-bin
.tar.gz
\
DISTFILES
=
apache-cassandra-
$(CASSANDRA_VERSION)
.tar.gz
;
http://apache.cs.utah.edu/cassandra/
$(CASSANDRA_VERSION)
/apache-cassandra-
$(CASSANDRA_VERSION)
-bin
.tar.gz
\
mosquitto-
$(MOSQUITTO_VERSION)
.tar.gz
;
http://mosquitto.org/files/source/mosquitto-
$(MOSQUITTO_VERSION)
.tar.gz
\
rudeconfig-5.0.5.tar.gz
;
http://rudeserver.com/config/download/rudeconfig-5.0.5.tar.gz
\
OpenIPMI-2.0.19.tar.gz
;
http://netcologne.dl.sourceforge.net/project/openipmi/OpenIPMI%202.0%20Library/OpenIPMI-2.0.19.tar.gz
\
boost_
$(BOOST_VERSION_U)
.tar.gz
;
http://netcologne.dl.sourceforge.net/project/boost/boost/
$(BOOST_VERSION)
/boost_
$(BOOST_VERSION_U)
.tar.gz
\
net-snmp-
$(SNMP_VERSION)
.zip
;
http://netcologne.dl.sourceforge.net/project/net-snmp/net-snmp/
$(SNMP_VERSION)
/net-snmp-
$(SNMP_VERSION)
.zip
\
openssl-
$(OPENSSL_VERSION)
.tar.gz
;
https://www.openssl.org/source/openssl-
$(OPENSSL_VERSION)
.tar.gz
\
libevent-
$(LIBEVENT_VERSION)
.tar.gz
;
https://cloud.github.com/downloads/libevent/libevent/libevent-
$(LIBEVENT_VERSION)
.tar.gz
\
cpp-driver-
$(CPPDRV_VERSION)
.tar.gz
;
https://github.com/datastax/cpp-driver/archive/1.0.0.tar.gz
\
libuv-v
$(LIBUV_VERSION)
.tar.gz
;
http://www.libuv.org/dist/v
$(LIBUV_VERSION)
/libuv-v
$(LIBUV_VERSION)
.tar.gz
...
...
@@ -114,18 +110,6 @@ $(DCDBDEPSPATH)/.prerequesites: $(DCDBDEPSPATH)/.extract-distfiles
echo
"Skipping OpenSSL library (already built)..."
;
\
fi
$(eval L
:
= $(shell echo "$(DISTFILESPATHS)" | sed 's/.*libevent/libevent/' | sed 's/
\
.*//'))
@
if
[
!
-e
$(DCDBDEPSPATH)
/
$(L)
/.installed
]
;
then
\
echo
""
;
\
echo
"Building libevent library..."
;
\
cd
$(DCDBDEPSPATH)
/
$(L)
&&
./configure
--prefix
=
$(DCDBDEPLOYPATH)
&&
\
make
-j
$(MAKETHREADS)
&&
\
make
install
&&
\
touch
$(DCDBDEPSPATH)
/
$(L)
/.installed
;
\
else
\
echo
"Skipping libevent library (already built)..."
;
\
fi
$(eval M
:
= $(shell echo "$(DISTFILESPATHS)" | sed 's/.*mosquitto/mosquitto/' | sed 's/
\
.*//'))
@
if
[
!
-e
$(DCDBDEPSPATH)
/
$(M)
/.installed
]
;
then
\
echo
""
;
\
...
...
@@ -190,24 +174,6 @@ $(DCDBDEPSPATH)/.prerequesites: $(DCDBDEPSPATH)/.extract-distfiles
echo
"Skipping Boost (already built)..."
;
\
fi
$(eval T
:
= $(shell echo "$(DISTFILESPATHS)" | sed 's/.*thrift/thrift/' | sed 's/
\
.*//'))
@
if
[
!
-e
$(DCDBDEPSPATH)
/
$(T)
/.installed
]
;
then
\
echo
""
;
\
echo
"Building Thrift..."
;
\
if
[
-e
$(DCDBDEPSPATH)
/patches/
$(T)
.patch
]
;
then
\
echo
"Patching Thrift..."
;
\
cd
$(DCDBDEPSPATH)
/
$(T)
&&
(
patch
-N
-p1
<
$(DCDBDEPSPATH)
/patches/
$(T)
.patch
||
true
)
;
\
fi
;
\
cd
$(DCDBDEPSPATH)
/
$(T)
&&
env
CXXFLAGS
=
"
$(CXX11FLAGS)
"
./configure
--prefix
=
$(DCDBDEPLOYPATH)
--without-qt4
--without-c_glib
\
--without-csharp
--without-java
--without-erlang
--without-nodejs
--without-lua
--without-python
--without-perl
\
--without-php
--without-php_extension
--without-ruby
--without-haskell
--without-go
--without-d
--with-cpp
\
--with-boost
=
$(DCDBDEPLOYPATH)
--enable-libtool-lock
--without-tests
--disable-tests
--with-openssl
=
$(DCDBDEPLOYPATH)
&&
\
env
CXXFLAGS
=
"
$(CXX11FLAGS)
"
make
-j
$(MAKETHREADS)
&&
\
env
CXXFLAGS
=
"
$(CXX11FLAGS)
"
make
install
&&
touch
$(DCDBDEPSPATH)
/
$(T)
/.installed
;
\
else
\
echo
"Skipping Thrift (already built)..."
;
\
fi
$(eval S
:
= $(shell echo "$(DISTFILESPATHS)" | sed 's/.*net-snmp/net-snmp/' | sed 's/
\
.*//'))
@
if
[
!
-e
$(DCDBDEPSPATH)
/
$(S)
/.installed
]
;
then
\
echo
""
;
\
...
...
patches/thrift-0.9.1.patch
deleted
100644 → 0
View file @
1d08ad02
Only in thrift-0.9.1-proper: .dirstamp
diff -r -U3 thrift-0.9.1/compiler/cpp/src/generate/t_java_generator.cc thrift-0.9.1-proper/compiler/cpp/src/generate/t_java_generator.cc
--- thrift-0.9.1/compiler/cpp/src/generate/t_java_generator.cc 2013-08-15 16:04:29.000000000 +0200
+++ thrift-0.9.1-proper/compiler/cpp/src/generate/t_java_generator.cc 2013-10-29 16:08:40.000000000 +0100
@@ -2824,10 +2824,9 @@
t_struct* xs = tfunction->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
- bool first = true;
if (xceptions.size() > 0) {
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
- first ? first = false : indent(f_service_) << "else ";
+ if (x_iter != xceptions.begin()) indent(f_service_) << "else ";
indent(f_service_) << "if (e instanceof " << type_name((*x_iter)->get_type(), false, false)<<") {" << endl;
indent(f_service_) << indent() << "result." << (*x_iter)->get_name() << " = (" << type_name((*x_iter)->get_type(), false, false) << ") e;" << endl;
indent(f_service_) << indent() << "result.set" << get_cap_name((*x_iter)->get_name()) << get_cap_name("isSet") << "(true);" << endl;
diff -r -U3 thrift-0.9.1/compiler/cpp/src/generate/t_rb_generator.cc thrift-0.9.1-proper/compiler/cpp/src/generate/t_rb_generator.cc
--- thrift-0.9.1/compiler/cpp/src/generate/t_rb_generator.cc 2013-08-15 16:04:29.000000000 +0200
+++ thrift-0.9.1-proper/compiler/cpp/src/generate/t_rb_generator.cc 2013-10-29 16:08:47.000000000 +0100
@@ -359,21 +359,19 @@
// Create a hash mapping values back to their names (as strings) since ruby has no native enum type
f_types_.indent() << "VALUE_MAP = {";
- bool first = true;
for(c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
// Populate the hash
int value = (*c_iter)->get_value();
- first ? first = false : f_types_ << ", ";
+ if (c_iter != constants.begin()) f_types_ << ", ";
f_types_ << value << " => \"" << capitalize((*c_iter)->get_name()) << "\"";
}
f_types_ << "}" << endl;
// Create a set with valid values for this enum
f_types_.indent() << "VALID_VALUES = Set.new([";
- first = true;
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
// Populate the set
- first ? first = false : f_types_ << ", ";
+ if (c_iter != constants.begin()) f_types_ << ", ";
f_types_ << capitalize((*c_iter)->get_name());
}
f_types_ << "]).freeze" << endl;
diff -r -U3 thrift-0.9.1/compiler/cpp/src/thrifty.yy thrift-0.9.1-proper/compiler/cpp/src/thrifty.yy
--- thrift-0.9.1/compiler/cpp/src/thrifty.yy 2013-08-15 16:04:29.000000000 +0200
+++ thrift-0.9.1-proper/compiler/cpp/src/thrifty.yy 2013-10-29 16:08:52.000000000 +0100
@@ -661,7 +661,7 @@
$$ = new t_const_value();
$$->set_integer($1);
if (!g_allow_64bit_consts && ($1 < INT32_MIN || $1 > INT32_MAX)) {
- pwarning(1, "64-bit constant \"%"PRIi64"\" may not work in all languages.\n", $1);
+ pwarning(1, "64-bit constant \"%" PRIi64 "\" may not work in all languages.\n", $1);
}
}
| tok_dub_constant
@@ -968,7 +968,7 @@
* warn if the user-specified negative value isn't what
* thrift would have auto-assigned.
*/
- pwarning(1, "Nonpositive field key (%"PRIi64") differs from what would be "
+ pwarning(1, "Nonpositive field key (%" PRIi64 ") differs from what would be "
"auto-assigned by thrift (%d).\n", $1, y_field_val);
}
/*
@@ -979,7 +979,7 @@
$$.value = $1;
$$.auto_assigned = false;
} else {
- pwarning(1, "Nonpositive value (%"PRIi64") not allowed as a field key.\n",
+ pwarning(1, "Nonpositive value (%" PRIi64 ") not allowed as a field key.\n",
$1);
$$.value = y_field_val--;
$$.auto_assigned = true;
diff -r -U3 thrift-0.9.1/tutorial/cpp/CppClient.cpp thrift-0.9.1-proper/tutorial/cpp/CppClient.cpp
--- thrift-0.9.1/tutorial/cpp/CppClient.cpp 2013-08-15 16:04:29.000000000 +0200
+++ thrift-0.9.1-proper/tutorial/cpp/CppClient.cpp 2013-10-29 16:08:55.000000000 +0100
@@ -38,9 +38,9 @@
using namespace boost;
int main(int argc, char** argv) {
- shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
- shared_ptr<TTransport> transport(new TBufferedTransport(socket));
- shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
+ boost::shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
+ boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
+ boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
CalculatorClient client(protocol);
try {
diff -r -U3 thrift-0.9.1/tutorial/cpp/CppServer.cpp thrift-0.9.1-proper/tutorial/cpp/CppServer.cpp
--- thrift-0.9.1/tutorial/cpp/CppServer.cpp 2013-08-15 16:04:29.000000000 +0200
+++ thrift-0.9.1-proper/tutorial/cpp/CppServer.cpp 2013-10-29 16:08:58.000000000 +0100
@@ -113,11 +113,11 @@
int main(int argc, char **argv) {
- shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
- shared_ptr<CalculatorHandler> handler(new CalculatorHandler());
- shared_ptr<TProcessor> processor(new CalculatorProcessor(handler));
- shared_ptr<TServerTransport> serverTransport(new TServerSocket(9090));
- shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
+ boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
+ boost::shared_ptr<CalculatorHandler> handler(new CalculatorHandler());
+ boost::shared_ptr<TProcessor> processor(new CalculatorProcessor(handler));
+ boost::shared_ptr<TServerTransport> serverTransport(new TServerSocket(9090));
+ boost::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
TSimpleServer server(processor,
serverTransport,
@@ -128,10 +128,10 @@
/**
* Or you could do one of these
- shared_ptr<ThreadManager> threadManager =
+ boost::shared_ptr<ThreadManager> threadManager =
ThreadManager::newSimpleThreadManager(workerCount);
- shared_ptr<PosixThreadFactory> threadFactory =
- shared_ptr<PosixThreadFactory>(new PosixThreadFactory());
+ boost::shared_ptr<PosixThreadFactory> threadFactory =
+ boost::shared_ptr<PosixThreadFactory>(new PosixThreadFactory());
threadManager->threadFactory(threadFactory);
threadManager->start();
TThreadPoolServer server(processor,
patches/thrift-0.9.2.patch
deleted
100644 → 0
View file @
1d08ad02
--- thrift-0.9.2/lib/cpp/src/thrift/protocol/TProtocol.h 2015-01-05 20:36:53.000000000 +0100
+++ thrift-0.9.2-proper/lib/cpp/src/thrift/protocol/TProtocol.h 2015-01-05 20:39:27.000000000 +0100
@@ -128,7 +128,7 @@
# elif defined(_MSC_VER) /* Microsoft Visual C++ */
# define ntohll(n) ( _byteswap_uint64((uint64_t)n) )
# define htonll(n) ( _byteswap_uint64((uint64_t)n) )
-# else /* Not GNUC/GLIBC or MSVC */
+# elif !defined(ntohll) /* Not GNUC/GLIBC or MSVC */
# define ntohll(n) ( (((uint64_t)ntohl((uint32_t)n)) << 32) + ntohl((uint32_t)(n >> 32)) )
# define htonll(n) ( (((uint64_t)htonl((uint32_t)n)) << 32) + htonl((uint32_t)(n >> 32)) )
# endif /* GNUC/GLIBC or MSVC or something else */
--- thrift-0.9.2/lib/cpp/test/processor/ProcessorTest.cpp.orig 2015-01-05 22:09:29.000000000 +0100
+++ thrift-0.9.2/lib/cpp/test/processor/ProcessorTest.cpp 2015-01-05 22:09:36.000000000 +0100
@@ -23,7 +23,6 @@
* implementations.
*/
-#include <tr1/functional>
#include <boost/test/unit_test.hpp>
#include <thrift/concurrency/PosixThreadFactory.h>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment