Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8DC1219DB2 for ; Wed, 30 Mar 2016 12:09:59 +0000 (UTC) Received: (qmail 70126 invoked by uid 500); 30 Mar 2016 12:09:59 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 70047 invoked by uid 500); 30 Mar 2016 12:09:59 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 69867 invoked by uid 99); 30 Mar 2016 12:09:59 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Mar 2016 12:09:59 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D1C6BE9432; Wed, 30 Mar 2016 12:09:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.apache.org Date: Wed, 30 Mar 2016 12:10:05 -0000 Message-Id: <61fe23f07b654fbb90173064c498942e@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [8/8] ignite git commit: Merge branch 'master' into ignite-1786 Merge branch 'master' into ignite-1786 Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/43bc846d Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/43bc846d Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/43bc846d Branch: refs/heads/ignite-1786 Commit: 43bc846d0cede479b897bafc197dd592731ad259 Parents: 607609d bbe5258 Author: vozerov-gridgain Authored: Wed Mar 30 15:09:52 2016 +0300 Committer: vozerov-gridgain Committed: Wed Mar 30 15:09:52 2016 +0300 ---------------------------------------------------------------------- .../processors/cache/CacheInvokeEntry.java | 41 ++- .../processors/cache/CacheLazyEntry.java | 9 +- .../processors/cache/GridCacheMapEntry.java | 9 +- .../GridCachePartitionExchangeManager.java | 8 +- .../processors/cache/GridCacheSwapManager.java | 26 +- .../distributed/dht/GridDhtTxPrepareFuture.java | 12 +- .../dht/atomic/GridDhtAtomicCache.java | 4 +- .../local/atomic/GridLocalAtomicCache.java | 4 +- .../cache/transactions/IgniteTxAdapter.java | 8 +- .../cache/transactions/IgniteTxEntry.java | 4 +- .../transactions/IgniteTxLocalAdapter.java | 5 +- .../processors/plugin/CachePluginManager.java | 25 ++ .../ignite/internal/visor/cache/VisorCache.java | 9 + .../internal/visor/cache/VisorCacheMetrics.java | 18 + .../internal/visor/cache/VisorCacheV3.java | 108 ++++++ .../visor/node/VisorNodeDataCollectorJob.java | 31 +- .../ignite/plugin/CachePluginProvider.java | 11 + ...cingDelayedPartitionMapExchangeSelfTest.java | 14 +- .../GridCacheRebalancingSyncSelfTest.java | 186 ++++++++++- .../junits/common/GridCommonAbstractTest.java | 53 ++- ...CacheDeploymentCachePluginConfiguration.java | 7 + modules/kafka/README.txt | 81 ++++- .../kafka/connect/IgniteSourceConnector.java | 81 +++++ .../kafka/connect/IgniteSourceConstants.java | 44 +++ .../stream/kafka/connect/IgniteSourceTask.java | 328 +++++++++++++++++++ .../serialization/CacheEventConverter.java | 66 ++++ .../serialization/CacheEventDeserializer.java | 54 +++ .../serialization/CacheEventSerializer.java | 54 +++ .../kafka/IgniteKafkaStreamerSelfTestSuite.java | 4 +- .../kafka/KafkaIgniteStreamerSelfTest.java | 11 +- .../ignite/stream/kafka/TestKafkaBroker.java | 27 +- .../kafka/connect/IgniteSinkConnectorTest.java | 13 +- .../connect/IgniteSourceConnectorMock.java | 31 ++ .../connect/IgniteSourceConnectorTest.java | 327 ++++++++++++++++++ .../kafka/connect/IgniteSourceTaskMock.java | 31 ++ .../kafka/connect/TestCacheEventFilter.java | 31 ++ .../kafka/src/test/resources/example-ignite.xml | 4 +- .../common/include/ignite/common/ignite_error.h | 15 +- .../platforms/cpp/common/src/ignite_error.cpp | 7 +- modules/platforms/cpp/core-test/Makefile.am | 1 + .../cpp/core-test/project/vs/core-test.vcxproj | 1 + .../project/vs/core-test.vcxproj.filters | 3 + .../cpp/core-test/src/ignite_error_test.cpp | 45 +++ .../Examples/ProjectFilesTest.cs | 2 +- 44 files changed, 1748 insertions(+), 105 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/43bc846d/modules/platforms/cpp/common/include/ignite/common/ignite_error.h ---------------------------------------------------------------------- diff --cc modules/platforms/cpp/common/include/ignite/common/ignite_error.h index 3b192b1,0000000..4097a62 mode 100644,000000..100644 --- a/modules/platforms/cpp/common/include/ignite/common/ignite_error.h +++ b/modules/platforms/cpp/common/include/ignite/common/ignite_error.h @@@ -1,265 -1,0 +1,274 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Declares ignite::IgniteError class. + */ + +#ifndef _IGNITE_ERROR +#define _IGNITE_ERROR + - #include +#include + ++#include ++#include ++ +#include + +#define IGNITE_ERROR_1(code, part1) { \ + std::stringstream stream; \ + stream << (part1); \ + throw ignite::IgniteError(code, stream.str().c_str()); \ +} + +#define IGNITE_ERROR_2(code, part1, part2) { \ + std::stringstream stream; \ + stream << (part1) << (part2); \ + throw ignite::IgniteError(code, stream.str().c_str()); \ +} + +#define IGNITE_ERROR_3(code, part1, part2, part3) { \ + std::stringstream stream; \ + stream << (part1) << (part2) << (part3); \ + throw ignite::IgniteError(code, stream.str().c_str()); \ +} + +#define IGNITE_ERROR_FORMATTED_1(code, msg, key1, val1) { \ + std::stringstream stream; \ + stream << msg << " [" << key1 << "=" << (val1) << "]"; \ + throw ignite::IgniteError(code, stream.str().c_str()); \ +} + +#define IGNITE_ERROR_FORMATTED_2(code, msg, key1, val1, key2, val2) { \ + std::stringstream stream; \ + stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << "]"; \ + throw ignite::IgniteError(code, stream.str().c_str()); \ +} + +#define IGNITE_ERROR_FORMATTED_3(code, msg, key1, val1, key2, val2, key3, val3) { \ + std::stringstream stream; \ + stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << "]"; \ + throw ignite::IgniteError(code, stream.str().c_str()); \ +} + +#define IGNITE_ERROR_FORMATTED_4(code, msg, key1, val1, key2, val2, key3, val3, key4, val4) { \ + std::stringstream stream; \ + stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << ", " << key4 << "=" << (val4) << "]"; \ + throw ignite::IgniteError(code, stream.str().c_str()); \ +} + +namespace ignite +{ + /** + * Ignite error information. + */ - class IGNITE_IMPORT_EXPORT IgniteError ++ class IGNITE_IMPORT_EXPORT IgniteError : public std::exception + { + public: + /** Success. */ + static const int IGNITE_SUCCESS = 0; + + /** Failed to initialize JVM. */ + static const int IGNITE_ERR_JVM_INIT = 1; + + /** Failed to attach to JVM. */ + static const int IGNITE_ERR_JVM_ATTACH = 2; + + /** JVM library is not found. */ + static const int IGNITE_ERR_JVM_LIB_NOT_FOUND = 3; + + /** Failed to load JVM library. */ + static const int IGNITE_ERR_JVM_LIB_LOAD_FAILED = 4; + + /** JVM classpath is not provided. */ + static const int IGNITE_ERR_JVM_NO_CLASSPATH = 5; + + /** JVM error: no class definition found. */ + static const int IGNITE_ERR_JVM_NO_CLASS_DEF_FOUND = 6; + + /** JVM error: no such method. */ + static const int IGNITE_ERR_JVM_NO_SUCH_METHOD = 7; + + /** Memory operation error. */ + static const int IGNITE_ERR_MEMORY = 1001; + + /** Binary error. */ + static const int IGNITE_ERR_BINARY = 1002; + + /** Generic Ignite error. */ + static const int IGNITE_ERR_GENERIC = 2000; + + /** Illegal argument passed. */ + static const int IGNITE_ERR_ILLEGAL_ARGUMENT = 2001; + + /** Illegal state. */ + static const int IGNITE_ERR_ILLEGAL_STATE = 2002; + + /** Unsupported operation. */ + static const int IGNITE_ERR_UNSUPPORTED_OPERATION = 2003; + + /** Thread has been interrup. */ + static const int IGNITE_ERR_INTERRUPTED = 2004; + + /** Cluster group is empty. */ + static const int IGNITE_ERR_CLUSTER_GROUP_EMPTY = 2005; + + /** Cluster topology problem. */ + static const int IGNITE_ERR_CLUSTER_TOPOLOGY = 2006; + + /** Compute execution rejected. */ + static const int IGNITE_ERR_COMPUTE_EXECUTION_REJECTED = 2007; + + /** Compute job failover. */ + static const int IGNITE_ERR_COMPUTE_JOB_FAILOVER = 2008; + + /** Compute task cancelled. */ + static const int IGNITE_ERR_COMPUTE_TASK_CANCELLED = 2009; + + /** Compute task timeout. */ + static const int IGNITE_ERR_COMPUTE_TASK_TIMEOUT = 2010; + + /** Compute user undeclared exception. */ + static const int IGNITE_ERR_COMPUTE_USER_UNDECLARED_EXCEPTION = 2011; + + /** Generic cache error. */ + static const int IGNITE_ERR_CACHE = 2012; + + /** Generic cache loader error. */ + static const int IGNITE_ERR_CACHE_LOADER = 2013; + + /** Generic cache writer error. */ + static const int IGNITE_ERR_CACHE_WRITER = 2014; + + /** Generic cache entry processor error. */ + static const int IGNITE_ERR_ENTRY_PROCESSOR = 2015; + + /** Cache atomic update timeout. */ + static const int IGNITE_ERR_CACHE_ATOMIC_UPDATE_TIMEOUT = 2016; + + /** Cache partial update. */ + static const int IGNITE_ERR_CACHE_PARTIAL_UPDATE = 2017; + + /** Transaction optimisitc exception. */ + static const int IGNITE_ERR_TX_OPTIMISTIC = 2018; + + /** Transaction timeout. */ + static const int IGNITE_ERR_TX_TIMEOUT = 2019; + + /** Transaction rollback. */ + static const int IGNITE_ERR_TX_ROLLBACK = 2020; + + /** Transaction heuristic exception. */ + static const int IGNITE_ERR_TX_HEURISTIC = 2021; + + /** Authentication error. */ + static const int IGNITE_ERR_AUTHENTICATION = 2022; + + /** Security error. */ + static const int IGNITE_ERR_SECURITY = 2023; + + /** Unknown error. */ + static const int IGNITE_ERR_UNKNOWN = -1; + + /** + * Throw an error if code is not IGNITE_SUCCESS. + * + * @param err Error. + */ + static void ThrowIfNeeded(IgniteError& err); + + /** + * Create empty error. + */ + IgniteError(); + + /** + * Create error with specific code. + * + * @param code Error code. + */ + IgniteError(const int32_t code); + + /** + * Create error with specific code and message. + * + * @param code Error code. + * @param msg Message. + */ + IgniteError(const int32_t code, const char* msg); + + /** + * Copy constructor. + * + * @param other Other instance. + */ + IgniteError(const IgniteError& other); + + /** + * Assignment operator. + * + * @param other Other instance. + * @return Assignment result. + */ + IgniteError& operator=(const IgniteError& other); + + /** + * Destructor. + */ + ~IgniteError(); + + /** + * Get error code. + * + * @return Error code. + */ + int32_t GetCode() const; + + /** + * Get error message. + * + * @return Error message. + */ + const char* GetText() const; - ++ ++ /** ++ * Get error message. Synonim for GetText(). ++ * ++ * @return Error message. ++ */ ++ virtual const char* what() const; ++ + /** + * Set error. + * + * @param jniCode Error code. + * @param jniCls Error class. + * @param jniMsg Error message. + * @param err Error. + */ + static void SetError(const int jniCode, const char* jniCls, const char* jniMsg, IgniteError* err); + private: + /** Error code. */ + int32_t code; + + /** Error message. */ + char* msg; + }; +} + +#endif http://git-wip-us.apache.org/repos/asf/ignite/blob/43bc846d/modules/platforms/cpp/common/src/ignite_error.cpp ---------------------------------------------------------------------- diff --cc modules/platforms/cpp/common/src/ignite_error.cpp index cd1b9c4,0000000..6981a86 mode 100644,000000..100644 --- a/modules/platforms/cpp/common/src/ignite_error.cpp +++ b/modules/platforms/cpp/common/src/ignite_error.cpp @@@ -1,221 -1,0 +1,226 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include + +using namespace ignite::common::java; +using namespace ignite::common::utils; + +namespace ignite +{ + void IgniteError::ThrowIfNeeded(IgniteError& err) + { + if (err.code != IGNITE_SUCCESS) + throw err; + } + + IgniteError::IgniteError() : code(IGNITE_SUCCESS), msg(NULL) + { + // No-op. + } + + IgniteError::IgniteError(int32_t code) : code(code), msg(NULL) + { + // No-op. + } + + IgniteError::IgniteError(int32_t code, const char* msg) + { + this->code = code; + this->msg = CopyChars(msg); + } + + IgniteError::IgniteError(const IgniteError& other) + { + this->code = other.code; + this->msg = CopyChars(other.msg); + } + + IgniteError& IgniteError::operator=(const IgniteError& other) + { + if (this != &other) + { + IgniteError tmp(other); + + int tmpCode = code; + char* tmpMsg = msg; + + code = tmp.code; + msg = tmp.msg; + + tmp.code = tmpCode; + tmp.msg = tmpMsg; + } + + return *this; + } + + IgniteError::~IgniteError() + { + ReleaseChars(msg); + } + + int32_t IgniteError::GetCode() const + { + return code; + } + + const char* IgniteError::GetText() const + { + if (code == IGNITE_SUCCESS) + return "Operation completed successfully."; + else if (msg) + return msg; + else + return "No additional information available."; + } - ++ ++ const char* IgniteError::what() const ++ { ++ return GetText(); ++ } ++ + void IgniteError::SetError(const int jniCode, const char* jniCls, const char* jniMsg, IgniteError* err) + { + if (jniCode == IGNITE_JNI_ERR_SUCCESS) + *err = IgniteError(); + else if (jniCode == IGNITE_JNI_ERR_GENERIC) + { + // The most common case when we have Java exception "in hands" and must map it to respective code. + if (jniCls) + { + std::string jniCls0 = jniCls; + + if (jniCls0.compare("java.lang.NoClassDefFoundError") == 0) + { + std::stringstream stream; + + stream << "Java class is not found (did you set IGNITE_HOME environment variable?)"; + + if (jniMsg) + stream << ": " << jniMsg; + + *err = IgniteError(IGNITE_ERR_JVM_NO_CLASS_DEF_FOUND, stream.str().c_str()); + } + else if (jniCls0.compare("java.lang.NoSuchMethodError") == 0) + { + std::stringstream stream; + + stream << "Java method is not found (did you set IGNITE_HOME environment variable?)"; + + if (jniMsg) + stream << ": " << jniMsg; + + *err = IgniteError(IGNITE_ERR_JVM_NO_SUCH_METHOD, stream.str().c_str()); + } + else if (jniCls0.compare("java.lang.IllegalArgumentException") == 0) + *err = IgniteError(IGNITE_ERR_ILLEGAL_ARGUMENT, jniMsg); + else if (jniCls0.compare("java.lang.IllegalStateException") == 0) + *err = IgniteError(IGNITE_ERR_ILLEGAL_STATE, jniMsg); + else if (jniCls0.compare("java.lang.UnsupportedOperationException") == 0) + *err = IgniteError(IGNITE_ERR_UNSUPPORTED_OPERATION, jniMsg); + else if (jniCls0.compare("java.lang.InterruptedException") == 0) + *err = IgniteError(IGNITE_ERR_INTERRUPTED, jniMsg); + else if (jniCls0.compare("org.apache.ignite.cluster.ClusterGroupEmptyException") == 0) + *err = IgniteError(IGNITE_ERR_CLUSTER_GROUP_EMPTY, jniMsg); + else if (jniCls0.compare("org.apache.ignite.cluster.ClusterTopologyException") == 0) + *err = IgniteError(IGNITE_ERR_CLUSTER_TOPOLOGY, jniMsg); + else if (jniCls0.compare("org.apache.ignite.compute.ComputeExecutionRejectedException") == 0) + *err = IgniteError(IGNITE_ERR_COMPUTE_EXECUTION_REJECTED, jniMsg); + else if (jniCls0.compare("org.apache.ignite.compute.ComputeJobFailoverException") == 0) + *err = IgniteError(IGNITE_ERR_COMPUTE_JOB_FAILOVER, jniMsg); + else if (jniCls0.compare("org.apache.ignite.compute.ComputeTaskCancelledException") == 0) + *err = IgniteError(IGNITE_ERR_COMPUTE_TASK_CANCELLED, jniMsg); + else if (jniCls0.compare("org.apache.ignite.compute.ComputeTaskTimeoutException") == 0) + *err = IgniteError(IGNITE_ERR_COMPUTE_TASK_TIMEOUT, jniMsg); + else if (jniCls0.compare("org.apache.ignite.compute.ComputeUserUndeclaredException") == 0) + *err = IgniteError(IGNITE_ERR_COMPUTE_USER_UNDECLARED_EXCEPTION, jniMsg); + else if (jniCls0.compare("javax.cache.CacheException") == 0) + *err = IgniteError(IGNITE_ERR_CACHE, jniMsg); + else if (jniCls0.compare("javax.cache.integration.CacheLoaderException") == 0) + *err = IgniteError(IGNITE_ERR_CACHE_LOADER, jniMsg); + else if (jniCls0.compare("javax.cache.integration.CacheWriterException") == 0) + *err = IgniteError(IGNITE_ERR_CACHE_WRITER, jniMsg); + else if (jniCls0.compare("javax.cache.processor.EntryProcessorException") == 0) + *err = IgniteError(IGNITE_ERR_ENTRY_PROCESSOR, jniMsg); + else if (jniCls0.compare("org.apache.ignite.cache.CacheAtomicUpdateTimeoutException") == 0) + *err = IgniteError(IGNITE_ERR_CACHE_ATOMIC_UPDATE_TIMEOUT, jniMsg); + else if (jniCls0.compare("org.apache.ignite.cache.CachePartialUpdateException") == 0) + *err = IgniteError(IGNITE_ERR_CACHE_PARTIAL_UPDATE, jniMsg); + else if (jniCls0.compare("org.apache.ignite.transactions.TransactionOptimisticException") == 0) + *err = IgniteError(IGNITE_ERR_TX_OPTIMISTIC, jniMsg); + else if (jniCls0.compare("org.apache.ignite.transactions.TransactionTimeoutException") == 0) + *err = IgniteError(IGNITE_ERR_TX_TIMEOUT, jniMsg); + else if (jniCls0.compare("org.apache.ignite.transactions.TransactionRollbackException") == 0) + *err = IgniteError(IGNITE_ERR_TX_ROLLBACK, jniMsg); + else if (jniCls0.compare("org.apache.ignite.transactions.TransactionHeuristicException") == 0) + *err = IgniteError(IGNITE_ERR_TX_HEURISTIC, jniMsg); + else if (jniCls0.compare("org.apache.ignite.IgniteAuthenticationException") == 0) + *err = IgniteError(IGNITE_ERR_AUTHENTICATION, jniMsg); + else if (jniCls0.compare("org.apache.ignite.plugin.security.GridSecurityException") == 0) + *err = IgniteError(IGNITE_ERR_SECURITY, jniMsg); + else if (jniCls0.compare("org.apache.ignite.IgniteException") == 0) + *err = IgniteError(IGNITE_ERR_GENERIC, jniMsg); + else if (jniCls0.compare("org.apache.ignite.IgniteCheckedException") == 0) + *err = IgniteError(IGNITE_ERR_GENERIC, jniMsg); + else + { + std::stringstream stream; + + stream << "Java exception occurred [cls=" << jniCls0; + + if (jniMsg) + stream << ", msg=" << jniMsg; + + stream << "]"; + + *err = IgniteError(IGNITE_ERR_UNKNOWN, stream.str().c_str()); + } + } + else + { + // JNI class name is not available. Something really weird. + *err = IgniteError(IGNITE_ERR_UNKNOWN); + } + } + else if (jniCode == IGNITE_JNI_ERR_JVM_INIT) + { + std::stringstream stream; + + stream << "Failed to initialize JVM [errCls="; + + if (jniCls) + stream << jniCls; + else + stream << "N/A"; + + stream << ", errMsg="; + + if (jniMsg) + stream << jniMsg; + else + stream << "N/A"; + + stream << "]"; + + *err = IgniteError(IGNITE_ERR_JVM_INIT, stream.str().c_str()); + } + else if (jniCode == IGNITE_JNI_ERR_JVM_ATTACH) + *err = IgniteError(IGNITE_ERR_JVM_ATTACH, "Failed to attach to JVM."); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/43bc846d/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj ----------------------------------------------------------------------