/** {@inheritDoc} */ @Override public String getZooKeeperEnsemble(final FijiURI uri) { return uri.getZooKeeperEnsemble(); } }
/** * Create a new ZooKeeper client for the cluster hosting the provided Fiji. The returned client is * already started, but the caller is responsible for closing it. The returned client *may* share * an underlying connection, therefore this method is not suitable if closing the client must * deterministically close outstanding session-based ZooKeeper items such as ephemeral nodes * or watchers. * * @param clusterURI of cluster to connect to. May not be null. * @return a ZooKeeper client using the new connection. */ public static CuratorFramework getZooKeeperClient(FijiURI clusterURI) { return getZooKeeperClient(clusterURI.getZooKeeperEnsemble()); }
/** {@inheritDoc} */ @Override protected void setup() throws Exception { super.setup(); boolean fijiURISpecified = mFijiURIFlag != null && !mFijiURIFlag.isEmpty(); boolean zkEnsembleSpecified = mZKEnsembleFlag != null && !mZKEnsembleFlag.isEmpty(); Preconditions.checkArgument(fijiURISpecified || zkEnsembleSpecified, "Specify the Fiji cluster URI or ZooKeeper ensemble to use for service discovery."); Preconditions.checkArgument( !(fijiURISpecified && zkEnsembleSpecified) || mFijiURIFlag.equals(KConstants.DEFAULT_INSTANCE_URI), "Specify either the Fiji cluster URI or the ZooKeeper ensemble."); if (zkEnsembleSpecified) { mZKEnsemble = mZKEnsembleFlag; } else if (fijiURISpecified) { mZKEnsemble = FijiURI.newBuilder(mFijiURIFlag).build().getZooKeeperEnsemble(); } else { throw new IllegalArgumentException( // This can't actually happen since the default fiji is used by default. "Must specify a ZooKeeper ensemble with --zookeeper-ensemble=host1:2181,host2:2181" + " or a Fiji cluster URI with --fiji=fiji://(host1,host2):2181/"); } }
throw new FijiNotInstalledException("Schema counter table not installed.", instanceURI); mZKClient = ZooKeeperUtils.getZooKeeperClient(instanceURI.getZooKeeperEnsemble()); mZKLock = new ZooKeeperLock(mZKClient, ZooKeeperUtils.getSchemaTableLock(mInstanceURI));