bool Ignition::Stop(const char* name, const bool cancel, IgniteError* err) { bool res = false; factoryLock.Enter(); if (started) { JniErrorInfo jniErr; SharedPointer<JniContext> ctx(JniContext::Create(NULL, 0, JniHandlers(), &jniErr)); IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err); if (err->GetCode() == IgniteError::IGNITE_SUCCESS) { char* name0 = CopyChars(name); bool res0 = ctx.Get()->IgnitionStop(name0, cancel, &jniErr); ReleaseChars(name0); IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err); if (err->GetCode() == IgniteError::IGNITE_SUCCESS) res = res0; } } factoryLock.Leave(); return res; }
JniHandlers IgniteEnvironment::GetJniHandlers(SharedPointer<IgniteEnvironment>* target) { JniHandlers hnds = JniHandlers(); hnds.target = target; hnds.onStart = OnStart; hnds.onStop = OnStop; hnds.error = NULL; return hnds; }
void Ignition::StopAll(const bool cancel, IgniteError* err) { factoryLock.Enter(); if (started) { JniErrorInfo jniErr; SharedPointer<JniContext> ctx(JniContext::Create(NULL, 0, JniHandlers(), &jniErr)); IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err); if (err->GetCode() == IgniteError::IGNITE_SUCCESS) { ctx.Get()->IgnitionStopAll(cancel, &jniErr); IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err); } } factoryLock.Leave(); }
Ignite Ignition::Get(const char* name, IgniteError* err) { Ignite res; factoryLock.Enter(); if (started) { char* name0 = CopyChars(name); // 1. Create context for this operation. JniErrorInfo jniErr; SharedPointer<JniContext> ctx(JniContext::Create(NULL, 0, JniHandlers(), &jniErr)); IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err); if (err->GetCode() == IgniteError::IGNITE_SUCCESS) { // 2. Get environment pointer. long long ptr = ctx.Get()->IgnitionEnvironmentPointer(name0, &jniErr); IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err); if (err->GetCode() == IgniteError::IGNITE_SUCCESS) { if (ptr != 0) { // 3. Obtain real environment for this instance. JniHandlers* hnds = reinterpret_cast<JniHandlers*>(ptr); SharedPointer<IgniteEnvironment>* env = static_cast<SharedPointer<IgniteEnvironment>*>(hnds->target); // 4. Get fresh node reference. jobject ref = ctx.Get()->IgnitionInstance(name0, &jniErr); if (err->GetCode() == IgniteError::IGNITE_SUCCESS) { if (ref) { IgniteImpl* impl = new IgniteImpl(*env, ref); res = Ignite(impl); } else // Error: concurrent node stop. *err = IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Failed to get Ignite instance because it was stopped concurrently."); } } else // Error: no node with the given name. *err = IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Failed to get Ignite instance because it is either not started yet or already stopped."); } } ReleaseChars(name0); } else // Error: no node with the given name. *err = IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Failed to get Ignite instance because it is either not started yet or already stopped."); factoryLock.Leave(); return res; }