Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2013-01-18 06:27:23 +0000
committerslewis2013-01-18 06:27:23 +0000
commitcb4d73609ca031c5649f855b57dd03ed7cfc1b9d (patch)
treefd978c47712e959929584ace3e62984713bd213d /providers/bundles/org.eclipse.ecf.provider.zookeeper
parent15d0cf001a6ca546eb08955b67a3fe7b9b51494e (diff)
parent6e0debee6465770c617adc3ca4c9c9e04e7c49b5 (diff)
downloadorg.eclipse.ecf-cb4d73609ca031c5649f855b57dd03ed7cfc1b9d.tar.gz
org.eclipse.ecf-cb4d73609ca031c5649f855b57dd03ed7cfc1b9d.tar.xz
org.eclipse.ecf-cb4d73609ca031c5649f855b57dd03ed7cfc1b9d.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.zookeeper')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.zookeeper/.settings/org.eclipse.jdt.core.prefs154
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.zookeeper/src/org/eclipse/ecf/provider/zookeeper/node/internal/WriteRoot.java330
2 files changed, 242 insertions, 242 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.zookeeper/.settings/org.eclipse.jdt.core.prefs b/providers/bundles/org.eclipse.ecf.provider.zookeeper/.settings/org.eclipse.jdt.core.prefs
index d9f2a537f..b79d790ad 100644
--- a/providers/bundles/org.eclipse.ecf.provider.zookeeper/.settings/org.eclipse.jdt.core.prefs
+++ b/providers/bundles/org.eclipse.ecf.provider.zookeeper/.settings/org.eclipse.jdt.core.prefs
@@ -1,77 +1,77 @@
-#Fri Oct 15 17:10:16 PDT 2010
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullReference=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.5
+#Fri Oct 15 17:10:16 PDT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/providers/bundles/org.eclipse.ecf.provider.zookeeper/src/org/eclipse/ecf/provider/zookeeper/node/internal/WriteRoot.java b/providers/bundles/org.eclipse.ecf.provider.zookeeper/src/org/eclipse/ecf/provider/zookeeper/node/internal/WriteRoot.java
index 3d362e6a9..859737be3 100644
--- a/providers/bundles/org.eclipse.ecf.provider.zookeeper/src/org/eclipse/ecf/provider/zookeeper/node/internal/WriteRoot.java
+++ b/providers/bundles/org.eclipse.ecf.provider.zookeeper/src/org/eclipse/ecf/provider/zookeeper/node/internal/WriteRoot.java
@@ -1,166 +1,166 @@
-/*******************************************************************************
- * Copyright (c)2010 REMAIN B.V. The Netherlands. (http://www.remainsoftware.com).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wim Jongman - initial API and implementation
- * Ahmed Aadel - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ecf.provider.zookeeper.node.internal;
-
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.data.Stat;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.ecf.provider.zookeeper.core.ZooDiscoveryContainer;
-import org.eclipse.ecf.provider.zookeeper.util.Logger;
-import org.eclipse.ecf.provider.zookeeper.util.PrettyPrinter;
-import org.osgi.service.log.LogService;
-
-class WriteRoot implements Watcher {
- private ZooKeeper writeKeeper;
- private String ip;
- private WatchManager watchManager;
- private boolean isConnected;
- private Object connectionLock = new Object();
-
- WriteRoot(String ip, WatchManager watchManager) {
- Assert.isNotNull(ip);
- Assert.isNotNull(watchManager);
- this.ip = ip;
- this.watchManager = watchManager;
- initWriteKeeper();
- }
-
- @SuppressWarnings({ "incomplete-switch" })
- public void process(final WatchedEvent event) {
- ZooDiscoveryContainer.CACHED_THREAD_POOL.execute(new Runnable() {
- public void run() {
- synchronized (connectionLock) {
- switch (event.getState()) {
- case Disconnected:
- isConnected = false;
- watchManager.unpublishAll();
- connect();
- break;
- case Expired:
- isConnected = false;
- watchManager.unpublishAll();
- connect();
- break;
- case SyncConnected:
- if (!isConnected) {
- isConnected = true;
- watchManager.addZooKeeper(writeKeeper);
- watchManager.republishAll();
- }
- break;
- // ignore @deprecated cases
- }
- }
- }
- });
- }
-
- private void connect() {
- synchronized (connectionLock) {
- if (this.isConnected || watchManager.isDisposed()) {
- return;
- }
- try {
- if (writeKeeper != null) {
- writeKeeper.close();
- watchManager.removeZooKeeper(writeKeeper);
- writeKeeper = null;
- }
- writeKeeper = new ZooKeeper(this.ip, 3000, this);
-
- } catch (Exception e) {
- Logger.log(LogService.LOG_DEBUG, e.getMessage(), e);
- }
- }
- }
-
- private void initWriteKeeper() {
- try {
- if (watchManager.getConfig().isQuorum()
- || watchManager.getConfig().isStandAlone()) {
- // we write nodes locally but we should check for client port.
- int port = watchManager.getConfig().getClientPort();
- if (port != 0)
- ip += ":" + port;//$NON-NLS-1$
- } else if (watchManager.getConfig().isCentralized()) {
- // we write nodes to the machine with this specified IP address.
- ip = watchManager.getConfig().getServerIps();
- }
- try {
- writeKeeper = new ZooKeeper(this.ip, 3000, this);
- } catch (Exception e) {
- // FATAL
- Logger.log(LogService.LOG_ERROR,
- "Fatal error while initializing a zookeeper client to write to: "
- + ip, e);
- // halt here before the NPE's get out of house in
- // Publisher.publish()
- throw new IllegalStateException(e);
- }
- while (!this.isConnected) {
- synchronized (connectionLock) {
- if (watchManager.isDisposed()) {
- // no need for connecting, we're disposed.
- try {
- writeKeeper.close();
- } catch (Throwable t) {
- // ignore
- }
- break;
- }
- try {
- Stat s = this.writeKeeper.exists(INode.ROOT, this);
- this.isConnected = true;
- if (s == null) {
- writeKeeper.create(INode.ROOT, new byte[0],
- Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
- }
-
- } catch (KeeperException e) {
- if (e.code()
- .equals(KeeperException.Code.CONNECTIONLOSS)) {
- isConnected = false;
- PrettyPrinter.attemptingConnectionTo(this.ip);
- } else
- Logger.log(
- LogService.LOG_ERROR,
- "Error while trying to connect to " + this.ip, e); //$NON-NLS-1$
- }
- }
- }
- synchronized (this) {
- this.notifyAll();
- }
-
- } catch (Exception e) {
- Logger.log(LogService.LOG_DEBUG, e.getMessage(), e);
- }
- }
-
- public ZooKeeper getWriteKeeper() {
- return writeKeeper;
- }
-
- public boolean isConnected() {
- return isConnected;
- }
-
- public WatchManager getWatchManager() {
- return watchManager;
- }
+/*******************************************************************************
+ * Copyright (c)2010 REMAIN B.V. The Netherlands. (http://www.remainsoftware.com).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wim Jongman - initial API and implementation
+ * Ahmed Aadel - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ecf.provider.zookeeper.node.internal;
+
+import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZooDefs.Ids;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.data.Stat;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.ecf.provider.zookeeper.core.ZooDiscoveryContainer;
+import org.eclipse.ecf.provider.zookeeper.util.Logger;
+import org.eclipse.ecf.provider.zookeeper.util.PrettyPrinter;
+import org.osgi.service.log.LogService;
+
+class WriteRoot implements Watcher {
+ private ZooKeeper writeKeeper;
+ private String ip;
+ private WatchManager watchManager;
+ private boolean isConnected;
+ private Object connectionLock = new Object();
+
+ WriteRoot(String ip, WatchManager watchManager) {
+ Assert.isNotNull(ip);
+ Assert.isNotNull(watchManager);
+ this.ip = ip;
+ this.watchManager = watchManager;
+ initWriteKeeper();
+ }
+
+ @SuppressWarnings({ "incomplete-switch" })
+ public void process(final WatchedEvent event) {
+ ZooDiscoveryContainer.CACHED_THREAD_POOL.execute(new Runnable() {
+ public void run() {
+ synchronized (connectionLock) {
+ switch (event.getState()) {
+ case Disconnected:
+ isConnected = false;
+ watchManager.unpublishAll();
+ connect();
+ break;
+ case Expired:
+ isConnected = false;
+ watchManager.unpublishAll();
+ connect();
+ break;
+ case SyncConnected:
+ if (!isConnected) {
+ isConnected = true;
+ watchManager.addZooKeeper(writeKeeper);
+ watchManager.republishAll();
+ }
+ break;
+ // ignore @deprecated cases
+ }
+ }
+ }
+ });
+ }
+
+ private void connect() {
+ synchronized (connectionLock) {
+ if (this.isConnected || watchManager.isDisposed()) {
+ return;
+ }
+ try {
+ if (writeKeeper != null) {
+ writeKeeper.close();
+ watchManager.removeZooKeeper(writeKeeper);
+ writeKeeper = null;
+ }
+ writeKeeper = new ZooKeeper(this.ip, 3000, this);
+
+ } catch (Exception e) {
+ Logger.log(LogService.LOG_DEBUG, e.getMessage(), e);
+ }
+ }
+ }
+
+ private void initWriteKeeper() {
+ try {
+ if (watchManager.getConfig().isQuorum()
+ || watchManager.getConfig().isStandAlone()) {
+ // we write nodes locally but we should check for client port.
+ int port = watchManager.getConfig().getClientPort();
+ if (port != 0)
+ ip += ":" + port;//$NON-NLS-1$
+ } else if (watchManager.getConfig().isCentralized()) {
+ // we write nodes to the machine with this specified IP address.
+ ip = watchManager.getConfig().getServerIps();
+ }
+ try {
+ writeKeeper = new ZooKeeper(this.ip, 3000, this);
+ } catch (Exception e) {
+ // FATAL
+ Logger.log(LogService.LOG_ERROR,
+ "Fatal error while initializing a zookeeper client to write to: "
+ + ip, e);
+ // halt here before the NPE's get out of house in
+ // Publisher.publish()
+ throw new IllegalStateException(e);
+ }
+ while (!this.isConnected) {
+ synchronized (connectionLock) {
+ if (watchManager.isDisposed()) {
+ // no need for connecting, we're disposed.
+ try {
+ writeKeeper.close();
+ } catch (Throwable t) {
+ // ignore
+ }
+ break;
+ }
+ try {
+ Stat s = this.writeKeeper.exists(INode.ROOT, this);
+ this.isConnected = true;
+ if (s == null) {
+ writeKeeper.create(INode.ROOT, new byte[0],
+ Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
+ }
+
+ } catch (KeeperException e) {
+ if (e.code()
+ .equals(KeeperException.Code.CONNECTIONLOSS)) {
+ isConnected = false;
+ PrettyPrinter.attemptingConnectionTo(this.ip);
+ } else
+ Logger.log(
+ LogService.LOG_ERROR,
+ "Error while trying to connect to " + this.ip, e); //$NON-NLS-1$
+ }
+ }
+ }
+ synchronized (this) {
+ this.notifyAll();
+ }
+
+ } catch (Exception e) {
+ Logger.log(LogService.LOG_DEBUG, e.getMessage(), e);
+ }
+ }
+
+ public ZooKeeper getWriteKeeper() {
+ return writeKeeper;
+ }
+
+ public boolean isConnected() {
+ return isConnected;
+ }
+
+ public WatchManager getWatchManager() {
+ return watchManager;
+ }
} \ No newline at end of file

Back to the top