Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions native/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-303658432693294100" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="789998405757277517" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-303658432693294100" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="789998405757277517" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
31 changes: 13 additions & 18 deletions native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
* permissions and limitations under the License. See accompanying
* LICENSE file.
*/
//plugins{
//id "de.undercouch.download" version "3.4.3"
//}

buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2' }
Expand Down Expand Up @@ -46,16 +42,16 @@ if ((rootProject.name.contains('native') && !rootProject.hasProperty('skipNative

String distDir = "${rootProject.projectDir}/dist"
String thriftVersion = '1.0.0-1'
String boostVersion = '1.59.0'
String newThriftVersion = '1.0.0-2'
String boostVersion = '1.69.0'
String mpirVersion = '2.7.2'
String opensslVersion = '1.0.2h'
String unixodbcVersion = '2.3.4'
String googletestVersion = '1.7.0'
String oldReleasesDir = "https://github.com/SnappyDataInc/thrift/releases/download/${thriftVersion}"
String oldReleasesDir = "https://github.com/SnappyDataInc/thrift/releases/download/${newThriftVersion}"

String releasesDir = oldReleasesDir

String newThriftVersion = '1.0.0-2'
String newBoostVersion = '1.65.1'
String newUnixodbcVersion = '2.3.4'
String newGoogletestVersion = '1.8.0'
Expand Down Expand Up @@ -142,8 +138,7 @@ if ((rootProject.name.contains('native') && !rootProject.hasProperty('skipNative
dependsOn downloadDependencies

inputs.files dependencies.collect { [ "${distDir}/${it}" ] }.flatten()
// outputs.files dependencies.collect { [ "${distDir}/${it.replaceAll('-[^-]*.tar.bz2', '')}" ] }.flatten()

//outputs.files dependencies.collect { [ "${distDir}/${it.replaceAll('-[^-]*.tar.bz2', '')}" ] }.flatten()
doLast {
outputs.files.each { d -> delete d }
dependencies.each { tarball ->
Expand Down Expand Up @@ -281,15 +276,15 @@ if ((rootProject.name.contains('native') && !rootProject.hasProperty('skipNative
'-rdynamic', '-ldl', '-z', 'defs'
} else if (toolChain in VisualCpp) {
// explicitly include UCRT since its still not passed through by gradle
String VS_2015_INCLUDE_DIR = 'C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt'
String VS_2015_LIB_DIR = 'C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/ucrt'
String VS_2015_INCLUDE_DIR_UM = 'C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/um'
String VS_2015_LIB_DIR_UM = 'C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/um'
String VS_2015_INCLUDE_DIR_SHARED = 'C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/shared'
String VS_2017_INCLUDE_DIR = 'C:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/ucrt'
String VS_2017_LIB_DIR = 'C:/Program Files (x86)/Windows Kits/10/Lib/10.0.17763.0/ucrt'
String VS_2017_INCLUDE_DIR_UM = 'C:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/um'
String VS_2017_LIB_DIR_UM = 'C:/Program Files (x86)/Windows Kits/10/Lib/10.0.17763.0/um'
String VS_2017_INCLUDE_DIR_SHARED = 'C:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/shared'
cppCompiler.args '/W3', '/FS', '/Zc:inline', '/WX', '/EHsc',
'/Fdsnappyclient.pdb', '/errorReport:prompt',
"/I${VS_2015_INCLUDE_DIR_UM}", "/I${VS_2015_INCLUDE_DIR_SHARED}",
"/I${VS_2015_INCLUDE_DIR}"
"/I${VS_2017_INCLUDE_DIR_UM}", "/I${VS_2017_INCLUDE_DIR_SHARED}",
"/I${VS_2017_INCLUDE_DIR}"
if (buildType == buildTypes.debug) {
cppCompiler.define '_DEBUG'
cppCompiler.args '/Od', '/Gm', '/ZI', '/RTC1', '/MDd'
Expand All @@ -298,9 +293,9 @@ if ((rootProject.name.contains('native') && !rootProject.hasProperty('skipNative
cppCompiler.args '/O2', '/GL', '/Oi', '/Gm-', '/Zi', '/MD'
}
if (targetPlatform == platforms.x64) {
linker.args "/LIBPATH:${VS_2015_LIB_DIR}/x64:${VS_2015_LIB_DIR_UM}/x64"
linker.args "/LIBPATH:${VS_2017_LIB_DIR}/x64:${VS_2017_LIB_DIR_UM}/x64"
} else {
linker.args "/LIBPATH:${VS_2015_LIB_DIR}/x86:${VS_2015_LIB_DIR_UM}/x86"
linker.args "/LIBPATH:${VS_2017_LIB_DIR}/x86:${VS_2017_LIB_DIR_UM}/x86"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions native/src/snappyclient/cpp/SQLState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ const SQLState SQLState::DATA_CONTAINER_CLOSED("40XD0",
ExceptionSeverity::TRANSACTION_SEVERITY);
const SQLState SQLState::THRIFT_PROTOCOL_ERROR("58015",
ExceptionSeverity::SESSION_SEVERITY);
const SQLState SQLState::NODE_BUCKET_MOVED("X0Z18",
ExceptionSeverity::TRANSACTION_SEVERITY);

void SQLState::staticInitialize() {
}
77 changes: 65 additions & 12 deletions native/src/snappyclient/cpp/impl/ClientService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ std::string ClientService::s_hostName;
std::string ClientService::s_hostId;
boost::mutex ClientService::s_globalLock;
bool ClientService::s_initialized = false;

std::set<std::string> NetConnection::failoverSQLStateSet={ "08001",
"08003", "08004", "08006", "X0J15", "X0Z32", "XN001", "XN014", "XN016",
"58009", "58014", "58015", "58016", "58017", "57017", "58010", "30021",
"XJ040", "XJ041", "XSDA3", "XSDA4", "XSDAJ", "XJ217" };
void DEFAULT_OUTPUT_FN(const char *str) {
LogWriter::info() << str << _SNAPPY_NEWLINE;
}
Expand Down Expand Up @@ -216,11 +219,23 @@ void ClientService::handleUnknownException(const char* op) {
}

void ClientService::handleSnappyException(const thrift::SnappyException& se) {
FailoverStatus status = NetConnection::getFailoverStatus(se.exceptionData.sqlState,se.exceptionData.errorCode,se);
if(status== FailoverStatus::NONE){
throw GET_SQLEXCEPTION(se);
}else if(status== FailoverStatus::RETRY){
// need to do failover to new server, so get the next one
//close the connection explicitly since server may still be alive
close();
std::set<thrift::HostAddress> failedServers;
updateFailedServersForCurrent(failedServers,true,nullptr);
thrift::HostAddress hostAddr= m_connHosts.at(0);
openConnection(hostAddr,failedServers);
}
}

void ClientService::handleTTransportException(const char* op,
const TTransportException& tte) {

checkConnection(op);

throwSQLExceptionForNodeFailure(op, tte);
Expand All @@ -235,18 +250,20 @@ void ClientService::handleTProtocolException(const char* op,
}

void ClientService::handleTException(const char* op, const TException& te) {
checkConnection(op);

handleStdException(op, te);
if (this->m_loadBalance){
// need to do failover to new server, so get the next one
//close the connection explicitly since server may still be alive
close();
std::set<thrift::HostAddress> failedServers;
updateFailedServersForCurrent(failedServers,true,nullptr);
thrift::HostAddress hostAddr= m_connHosts.at(0);
openConnection(hostAddr,failedServers);
}else{
checkConnection(op);

handleStdException(op, te);
}
}
/*
void ClientService::handleException(const TException* te,
const std::set<thrift::HostAddress>& failedServers, bool tryFailover, bool ignoreFailOver,
bool createNewConnection, const std::string& op)
{

}*/

void ClientService::throwSQLExceptionForNodeFailure(const char* op,
const std::exception& se) {
std::ostringstream hostAddrStr;
Expand Down Expand Up @@ -1518,3 +1535,39 @@ void ClientService::updateFailedServersForCurrent(
controlService->searchRandomServer(failedServers, failure, pHost);
}
}
//void ClientService::
FailoverStatus NetConnection::getFailoverStatus(const std::string& sqlState,const int32_t& errorCode, const TException& snappyEx){
if(! std::strcmp(SQLState::SNAPPY_NODE_SHUTDOWN.getSQLState(),sqlState.c_str())
|| std::strcmp(SQLState::NODE_BUCKET_MOVED.getSQLState(),sqlState.c_str())){
return FailoverStatus::RETRY;
}
/* for 08001 we have to, unfortunately, resort to string search to
* determine if failover makes sense or it is due to some problem
* with authentication or invalid properties */
else if(!sqlState.compare("08001")){
std::string msg(snappyEx.what());
if(!msg.empty() &&
((msg.find("rror")!=std::string::npos) // cater to CONNECT_UNABLE_TO_CONNECT_TO_SERVER
|| (msg.find("xception")!=std::string::npos ) // cater to CONNECT_SOCKET_EXCEPTION
||(msg.find("ocket")!=std::string::npos))// cater to CONNECT_UNABLE_TO_OPEN_SOCKET_STREAM
){
return FailoverStatus::NEW_SERVER;
}
}
/* for 08004 we have to, unfortunately, resort to string search to
* determine if failover makes sense or it is due to some problem
* with authentication
*/
else if(!sqlState.compare("08004")){
std::string msg(snappyEx.what());
if(!msg.empty() &&
(msg.find("connection refused") !=std::string::npos)
){
return FailoverStatus::NEW_SERVER;
}
}
else if(failoverSQLStateSet.find(sqlState)!= failoverSQLStateSet.end()){
return FailoverStatus::NEW_SERVER;
}
return FailoverStatus::NONE;
}
13 changes: 12 additions & 1 deletion native/src/snappyclient/cpp/impl/ClientService.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ namespace impl {

class ClientTransport;
class ControlConnection;

enum class FailoverStatus :unsigned char{
NONE, /** no failover to be done */
NEW_SERVER, /** failover to a new server */
RETRY /** retry to the same server */
};
class SnappyDataClient : public thrift::SnappyDataServiceClient {
public:
SnappyDataClient(protocol::TProtocol* prot) :
Expand Down Expand Up @@ -359,7 +363,14 @@ namespace impl {
}

};
class NetConnection{
private:

/** set of SQLState strings that denote failover should be done */
static std::set<std::string> failoverSQLStateSet;
public:
static FailoverStatus getFailoverStatus(const std::string& sqlState,const int32_t& errorCode, const TException& snappyEx);
};
} /* namespace impl */
} /* namespace client */
} /* namespace snappydata */
Expand Down
Loading