From c5efc8a165778b83bf0256663c8f6d69348bb929 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Thu, 8 Feb 2018 22:20:59 +0100 Subject: Remove no longer used frtstream --- frtstream/.gitignore | 1 - frtstream/CMakeLists.txt | 12 -- frtstream/OWNERS | 1 - frtstream/README | 1 - frtstream/docs/introduction.txt | 27 --- frtstream/src/.gitignore | 4 - frtstream/src/example/.gitignore | 3 - frtstream/src/example/CMakeLists.txt | 2 - frtstream/src/example/simple.cpp | 39 ---- frtstream/src/example/test.cpp | 72 -------- frtstream/src/vespa/frtstream/.gitignore | 2 - frtstream/src/vespa/frtstream/CMakeLists.txt | 7 - frtstream/src/vespa/frtstream/frtclientstream.cpp | 57 ------ frtstream/src/vespa/frtstream/frtclientstream.h | 31 ---- frtstream/src/vespa/frtstream/frtserverstream.h | 28 --- frtstream/src/vespa/frtstream/frtstream.cpp | 64 ------- frtstream/src/vespa/frtstream/frtstream.h | 90 --------- .../src/vespa/frtstream/frtstreamTemplateImp.hpp | 202 --------------------- 18 files changed, 643 deletions(-) delete mode 100644 frtstream/.gitignore delete mode 100644 frtstream/CMakeLists.txt delete mode 100644 frtstream/OWNERS delete mode 100644 frtstream/README delete mode 100644 frtstream/docs/introduction.txt delete mode 100644 frtstream/src/.gitignore delete mode 100644 frtstream/src/example/.gitignore delete mode 100644 frtstream/src/example/CMakeLists.txt delete mode 100644 frtstream/src/example/simple.cpp delete mode 100644 frtstream/src/example/test.cpp delete mode 100644 frtstream/src/vespa/frtstream/.gitignore delete mode 100644 frtstream/src/vespa/frtstream/CMakeLists.txt delete mode 100644 frtstream/src/vespa/frtstream/frtclientstream.cpp delete mode 100644 frtstream/src/vespa/frtstream/frtclientstream.h delete mode 100644 frtstream/src/vespa/frtstream/frtserverstream.h delete mode 100644 frtstream/src/vespa/frtstream/frtstream.cpp delete mode 100644 frtstream/src/vespa/frtstream/frtstream.h delete mode 100644 frtstream/src/vespa/frtstream/frtstreamTemplateImp.hpp (limited to 'frtstream') diff --git a/frtstream/.gitignore b/frtstream/.gitignore deleted file mode 100644 index f3c7a7c5da6..00000000000 --- a/frtstream/.gitignore +++ /dev/null @@ -1 +0,0 @@ -Makefile diff --git a/frtstream/CMakeLists.txt b/frtstream/CMakeLists.txt deleted file mode 100644 index 0359827d338..00000000000 --- a/frtstream/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_define_module( - DEPENDS - fastos - fnet - - LIBS - src/vespa/frtstream - - TESTS - src/example -) diff --git a/frtstream/OWNERS b/frtstream/OWNERS deleted file mode 100644 index 31af040f698..00000000000 --- a/frtstream/OWNERS +++ /dev/null @@ -1 +0,0 @@ -bratseth diff --git a/frtstream/README b/frtstream/README deleted file mode 100644 index 6c53b361cdd..00000000000 --- a/frtstream/README +++ /dev/null @@ -1 +0,0 @@ -Library used by file distribution. \ No newline at end of file diff --git a/frtstream/docs/introduction.txt b/frtstream/docs/introduction.txt deleted file mode 100644 index d733d7be0da..00000000000 --- a/frtstream/docs/introduction.txt +++ /dev/null @@ -1,27 +0,0 @@ -FrtStream provides an iostream like interface to Frt. It consists of -two main parts: FrtClientStream and FrtServerStream. Both streams can -read/write integers, floating point numbers, strings(std), and -standard c++ containers containing these types. Other types can be -added by operator overloading.( like for iostreams ) - -FrtClientStream -This is a complete abstraction for making simple Frt clients. -It's used the following way: - -FrtClientStream s(); -s <) <> result1 >>result2 ... >>resultn - -s <) ... - - - -FrtServerStream -This is currently only a wrapper to use around Request -objects on the server to ease working with parameters and return -values. It's used inside method handlers by making a FrtServerStream -on the stack and passing the request object to it's constructor: - -FrtServerStream s(request); -s >>param1 >>param2 .... >>paramn -s < - -#include - -using namespace std; -using frtstream::FrtClientStream; -using frtstream::Method; -using frtstream::InvokationException; - -const string connectionSpec = "tcp/test-tonyv:9997"; - -class TestApp : public FastOS_Application { -public: - int Main() { - FrtClientStream s(connectionSpec); - - try { - s <> res; - - cout <<"Result = " < - -#include -#include -#include -#include -#include - -using namespace std; -using frtstream::FrtClientStream; -using frtstream::Method; -using frtstream::InvokationException; - -const string connectionSpec = "tcp/test-tonyv:9997"; - -class TestApp : public FastOS_Application { -public: - int Main() { - FrtClientStream s(connectionSpec); - - std::vector vec; - vec.push_back("Hello"); vec.push_back("world"); - - std::set codeSet; - codeSet.insert("abc"); codeSet.insert("def"); - - std::vector doubleVec; - doubleVec.push_back(99.98); doubleVec.push_back(98.97); - - std::vector floatVec; - floatVec.push_back(99.98); floatVec.push_back(98.97); - - uint8_t i1 = 1; - int8_t i2 = 2; - - uint16_t i3 = 1; - int16_t i4 = 2; - - uint32_t i5 = 1; - int32_t i6 = 2; - - uint64_t i7 = 1; - int64_t i8 = 2; - - float f1 = 3.14; - double d1 = 123.456; - - try { - s <> res >>vec >>codeSet >>doubleVec >>floatVec >>i1 >>f1 >>d1 - >>i1 >>i2 >>i3 >>i4 >>i5 >>i6 >>i7 >>i8; - - cout <<"Result = " < -#include - -using namespace fnet; - -namespace frtstream { - -FrtClientStream::FrtClientStream(const std::string& connectionSpec) - : timeout(30), - executed(false), - _nextOutValue(0) - -{ - supervisor.Start(); - target = supervisor.GetTarget(connectionSpec.c_str()); - if( ! target ) { - supervisor.ShutDown(true); - throw ConnectionException(); - } - request = supervisor.AllocRPCRequest(); -} - -FrtClientStream::~FrtClientStream() { - request->SubRef(); - target->SubRef(); - supervisor.ShutDown(true); -} - -FrtClientStream& FrtClientStream::operator<<(const Method& m) { - executed = false; - request = supervisor.AllocRPCRequest(request); - request->SetMethodName(m.name().c_str()); - - return *this; -} - -FRT_Values& FrtClientStream::in() { - return *request->GetParams(); -} -FRT_Value& FrtClientStream::nextOut() { - if(! executed ) { - target->InvokeSync(request, timeout); - executed = true; - _nextOutValue = 0; - if( request->GetErrorCode() != FRTE_NO_ERROR ) { - throw InvokationException(request->GetErrorCode(), - request->GetErrorMessage()); - } - } - return request->GetReturn()->GetValue(_nextOutValue++); -} - - -} //end namespace frtstream diff --git a/frtstream/src/vespa/frtstream/frtclientstream.h b/frtstream/src/vespa/frtstream/frtclientstream.h deleted file mode 100644 index 7c0eb6f720a..00000000000 --- a/frtstream/src/vespa/frtstream/frtclientstream.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -#include "frtstream.h" -#include - -namespace frtstream { - -class FrtClientStream : public FrtStream { - FRT_Supervisor supervisor; - FRT_RPCRequest* request; - const double timeout; - - FRT_Target* target; - bool executed; - uint32_t _nextOutValue; - - FRT_Values& in() override; - FRT_Value& nextOut() override; -public: - FrtClientStream(const std::string& connectionSpec); - ~FrtClientStream(); - - using FrtStream::operator<<; - using FrtStream::operator>>; - FrtClientStream& operator<<(const Method& m); -}; - -} //end namespace frtstream - diff --git a/frtstream/src/vespa/frtstream/frtserverstream.h b/frtstream/src/vespa/frtstream/frtserverstream.h deleted file mode 100644 index aefe2c8639b..00000000000 --- a/frtstream/src/vespa/frtstream/frtserverstream.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -#include - -namespace frtstream { - -class FrtServerStream : public FrtStream { - FRT_RPCRequest* request; - uint32_t _nextOutValue; - - FRT_Values& in() override { - return *request->GetReturn(); - } - - FRT_Value& nextOut() override { - return request->GetParams()->GetValue(_nextOutValue++); - } -public: - FrtServerStream(FRT_RPCRequest* req) : - request(req), - _nextOutValue(0) {} - - using FrtStream::operator<<; - using FrtStream::operator>>; -}; - -} //end namespace frtstream diff --git a/frtstream/src/vespa/frtstream/frtstream.cpp b/frtstream/src/vespa/frtstream/frtstream.cpp deleted file mode 100644 index 6a3a3b72641..00000000000 --- a/frtstream/src/vespa/frtstream/frtstream.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "frtstream.h" -#include -#include - -using namespace fnet; - -namespace frtstream { - - - -#define _FRTSTREAM_INTEGER_OPERATOR(bits) \ -FrtStream& FrtStream::operator<<(uint##bits##_t i) { \ - in().AddInt##bits(i); \ - return *this; \ -} \ -FrtStream& FrtStream::operator>>(uint##bits##_t &i) { \ - i = nextOut()._intval##bits; \ - return *this; \ -} - -_FRTSTREAM_INTEGER_OPERATOR(8); -_FRTSTREAM_INTEGER_OPERATOR(16); -_FRTSTREAM_INTEGER_OPERATOR(32); -_FRTSTREAM_INTEGER_OPERATOR(64); -#undef _FRTSTREAM_INTEGER_OPERATOR - -#define _FRTSTREAM_FLOAT_OPERATOR(floatType, floatTypeCapitalized) \ -FrtStream& FrtStream::operator<<(floatType i) { \ - in().Add##floatTypeCapitalized(i); \ - return *this; \ -} \ -FrtStream& FrtStream::operator>>(floatType &i) { \ - i = nextOut()._##floatType; \ - return *this; \ -} - -_FRTSTREAM_FLOAT_OPERATOR(float, Float); -_FRTSTREAM_FLOAT_OPERATOR(double, Double); -#undef _FRTSTREAM_FLOAT_OPERATOR - -FrtStream& FrtStream::operator<<(const std::string &str) { - in().AddString(str.c_str()); - return *this; -} - -FrtStream& FrtStream::operator>>(std::string &str) { - str = nextOut()._string._str; - return *this; -} - - -std::ostream& operator<<(std::ostream& s, const InvokationException& e) { - s <<"InvocationException: " < -#include -#include -#include -#include -#include - -namespace frtstream { - -class ConnectionException{}; -class InvokationException{ -public: - - uint32_t errorCode; - std::string errorMessage; - InvokationException(uint32_t code, const std::string& msg ): - errorCode(code), errorMessage(msg) {} -}; - -std::ostream& operator<<(std::ostream& s, const InvokationException& e); - - -class Method { - std::string _name; -public: - Method(const std::string& methodName) : - _name(methodName) {} - //implement in the future along with typechecking - //Method(const std::string& name, const std::string& typeString); - - std::string name() const { - return _name; - } -}; - -class FrtStream { -protected: - virtual FRT_Values& in() = 0; - virtual FRT_Value& nextOut() = 0; - -public: - virtual ~FrtStream() {} - -#define _FRTSTREAM_INTOPERATOR(bits) \ - FrtStream& operator<<(uint##bits##_t); \ - FrtStream& operator>>(uint##bits##_t&); \ - FrtStream& operator<<(int##bits##_t val) { \ - operator<<(static_cast(val)); \ - return *this; \ - } \ - FrtStream& operator>>(int##bits##_t &val) { \ - uint##bits##_t temp; \ - *this>>temp; \ - val = static_cast(val); \ - return *this; \ - } - - _FRTSTREAM_INTOPERATOR(8); - _FRTSTREAM_INTOPERATOR(16); - _FRTSTREAM_INTOPERATOR(32); - _FRTSTREAM_INTOPERATOR(64); -#undef _FRTSTREAM_INTOPERATOR - - FrtStream& operator<<(float); - FrtStream& operator>>(float&); - - FrtStream& operator<<(double); - FrtStream& operator>>(double&); - - FrtStream& operator<<(const std::string &str); - FrtStream& operator>>(std::string &str); - - FrtStream& operator<<(std::string &str); - - template class CONT, class T, class ALLOC> - FrtStream& operator<<( const CONT & cont ); - - template class CONT, class T, class ALLOC> - FrtStream& operator>>( CONT & cont ); -}; - - -} //end namespace frtstream - - -#include "frtstreamTemplateImp.hpp" - diff --git a/frtstream/src/vespa/frtstream/frtstreamTemplateImp.hpp b/frtstream/src/vespa/frtstream/frtstreamTemplateImp.hpp deleted file mode 100644 index bea6d2a9fac..00000000000 --- a/frtstream/src/vespa/frtstream/frtstreamTemplateImp.hpp +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -//template functions that must be included in the -//header file, since the full definition needs to be -//available to users. -//Can be moved when(if ever) the export functionality -//is implemented in the target compiler. - -namespace frtstream { - -template -struct FrtStreamConverter{ - typedef U type; - typedef U serializationType; - - static const serializationType& convertTo(const U& u) { - return u; - } - static const U& convertFrom(const serializationType& s) { - return s; - } - -}; - -//signed conversion -#define _FRTSTREAM_CONVERTUNSIGNED_(signedType) \ -template <> \ -struct FrtStreamConverter< signedType > { \ - typedef u##signedType serializationType; \ -\ - static serializationType convertTo(signedType u) { \ - return static_cast< serializationType >(u); \ - } \ - static signedType convertFrom(serializationType s) { \ - return static_cast< signedType >(s); \ - } \ -}; - -_FRTSTREAM_CONVERTUNSIGNED_(int8_t); -_FRTSTREAM_CONVERTUNSIGNED_(int16_t); -_FRTSTREAM_CONVERTUNSIGNED_(int32_t); -_FRTSTREAM_CONVERTUNSIGNED_(int64_t); - -#undef _FRTSTREAM_CONVERTUNSIGNED_ -//end signed conversion - - -template -struct FrtArray { - T* _pt; - uint32_t _len; -}; - - -//ArrayTypeUtil - -//Little ugly hack to avoid code duplication -//Needed since template based approach failed -//to work because of anonymous type. -#define _FRTSTREAM_FILLARRAY(arr, prefix) \ -arr._pt = prefix._pt; \ -arr._len = prefix._len; - - -void PleaseAddSpecializationForYourType(); - -template -struct ArrayTypeUtil { - template - static void addArray(FRT_Values& value, const Cont& c) { - frtstream::PleaseAddSpecializationForYourType(); - } - - static void getArray(FRT_Value& value) { - frtstream::PleaseAddSpecializationForYourType(); - } -}; - -template <> -struct ArrayTypeUtil { - template - struct AddString{ - FRT_StringValue* ptr; - FRT_Values& values; - - AddString(FRT_StringValue* start, FRT_Values& val) : - ptr(start), values(val) {} - void operator()(const typename Converter::type& s) { - values.SetString(ptr++, Converter::convertTo(s).c_str()); - } - }; - - - template - static void addArray(FRT_Values& value, const Cont& c) { - FRT_StringValue* start = value.AddStringArray(c.size()); - std::for_each(c.begin(), c.end(), AddString(start, value)); - - } - static FrtArray getArray(FRT_Value& value) { - FrtArray arr; - _FRTSTREAM_FILLARRAY(arr, value._string_array); - return arr; - } - -}; - -#define _FRTSTREAM_ARRAYTYPE_UTIL_FLOAT(floatType, floatTypeCapitalized) \ -template <> \ -struct ArrayTypeUtil { \ - template \ - static void addArray(FRT_Values& values, const Cont & cont) { \ - floatType* startPtr = values.Add##floatTypeCapitalized##Array(cont.size()); \ - std::transform(cont.begin(), cont.end(), startPtr, Converter::convertTo); \ - } \ - static FrtArray getArray(FRT_Value& value) { \ - FrtArray arr; \ - _FRTSTREAM_FILLARRAY(arr, value._##floatType##_array); \ - return arr; \ - } \ -}; - -_FRTSTREAM_ARRAYTYPE_UTIL_FLOAT(float, Float); -_FRTSTREAM_ARRAYTYPE_UTIL_FLOAT(double, Double); -#undef _FRTSTREAM_ARRAYTYPE_UTIL_FLOAT - -#define _FRTSTREAM_ARRAYTYPE_UTIL_INT(bits) \ -template <> \ -struct ArrayTypeUtil { \ - template \ - static void addArray(FRT_Values& values, const Cont & cont) { \ - uint##bits##_t* startPtr = values.AddInt##bits##Array(cont.size()); \ - std::transform(cont.begin(), cont.end(), startPtr, \ - Converter::convertTo); \ - } \ -\ - static FrtArray getArray(FRT_Value& value) { \ - FrtArray arr; \ - _FRTSTREAM_FILLARRAY(arr, value._int##bits##_array); \ - return arr; \ - } \ -}; - -_FRTSTREAM_ARRAYTYPE_UTIL_INT(8); -_FRTSTREAM_ARRAYTYPE_UTIL_INT(16); -_FRTSTREAM_ARRAYTYPE_UTIL_INT(32); -_FRTSTREAM_ARRAYTYPE_UTIL_INT(64); -#undef _FRTSTREAM_ARRAYTYPE_UTIL_INT - -#undef _FRTSTREAM_FILLARRAY -//End ArrayTypeUtil - -//ArrayReader -template -struct ArrayReader { - template - static void read(Iter dest, ArrayImp arr) { - std::transform( arr._pt, arr._pt + arr._len, dest, - Converter::convertFrom ); - - } -}; - -template <> -struct ArrayReader { - template - static void read(Iter dest, ArrayImp arr) { - FRT_StringValue* ptr = arr._pt; - for(uint32_t i = 0; i < arr._len; i++ ) { - *dest++ = Converter::convertFrom(ptr++ ->_str); - } - } -}; - - - -//End ArrayReader - - -template class CONT, class T, class ALLOC> -FrtStream& FrtStream::operator<<( const CONT & cont ) { - typedef FrtStreamConverter::value_type> Converter; - typedef typename FrtStreamConverter::value_type>::serializationType SerializationType; - - frtstream::ArrayTypeUtil::template addArray(in(), cont); - - return *this; -} - - - -template class CONT, class T, class ALLOC> -FrtStream& FrtStream::operator>>( CONT & cont ) { - typedef FrtStreamConverter::value_type> Converter; - typedef typename FrtStreamConverter::value_type>::serializationType SerializationType; - - ArrayReader::template read( std::inserter(cont, cont.end()), - ArrayTypeUtil::getArray(nextOut()) ); - - return *this; -} - -} //end namespace frtstream -- cgit v1.2.3