private synchronized CuratorFramework getAppCurator() { if (appCurator == null) { appCurator = CuratorUtil.newAppCurator(config); appCurator.start(); } return appCurator; }
public static void updateSharedConfig(CuratorFramework curator, Properties sharedProps) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); sharedProps.store(baos, "Shared java props"); CuratorUtil.putData(curator, ZookeeperPath.CONFIG_SHARED, baos.toByteArray(), CuratorUtil.NodeExistsPolicy.OVERWRITE); }
/** * Creates a curator built using Fluo's zookeeper connection string. Root path will start at Fluo * chroot. */ public static CuratorFramework newFluoCurator(FluoConfiguration config) { return newCurator(config.getInstanceZookeepers(), config.getZookeeperTimeout()); }
private void createZkNode(long ts) { Preconditions.checkState(node == null, "expected node to be null"); node = new PersistentEphemeralNode(env.getSharedResources().getCurator(), Mode.EPHEMERAL, getNodePath(), LongUtil.toByteArray(ts)); CuratorUtil.startAndWait(node, 10); zkTimestamp = ts; }
public FluoAdminImpl(FluoConfiguration config) { this.config = config; if (!config.hasRequiredAdminProps()) { throw new IllegalArgumentException("Admin configuration is missing required properties"); } appRootDir = ZookeeperUtil.parseRoot(config.getAppZookeepers()); rootCurator = CuratorUtil.newRootFluoCurator(config); rootCurator.start(); }
public void list(FluoConfiguration config) { try (CuratorFramework curator = CuratorUtil.newFluoCurator(config)) { curator.start();
/** * Creates a transactor node using given transactor id * * @param env Environment * @param tid Transactor ID used to create node */ public TransactorNode(Environment env, TransactorID tid) { this.env = env; this.tid = tid; node = new PersistentEphemeralNode(env.getSharedResources().getCurator(), Mode.EPHEMERAL, getNodePath(), tid.toString().getBytes()); CuratorUtil.startAndWait(node, 10); status = TrStatus.OPEN; }
private synchronized CuratorFramework getAppCurator(FluoConfiguration config) { if (!curators.containsKey(config.getApplicationName())) { CuratorFramework curator = CuratorUtil.newAppCurator(config); curator.start(); curators.put(config.getApplicationName(), curator); } return curators.get(config.getApplicationName()); }
public static void updateObservers(CuratorFramework curator, Map<Column, ObserverConfiguration> colObservers, Map<Column, ObserverConfiguration> weakObservers) throws Exception { // TODO check that no workers are running... or make workers watch this znode String observerPath = ZookeeperPath.CONFIG_FLUO_OBSERVERS; try { curator.delete().deletingChildrenIfNeeded().forPath(observerPath); } catch (NoNodeException nne) { // it's ok if node doesn't exist } catch (Exception e) { logger.error("An error occurred deleting Zookeeper node. node=[" + observerPath + "], error=[" + e.getMessage() + "]"); throw new RuntimeException(e); } byte[] serializedObservers = serializeObservers(colObservers, weakObservers); CuratorUtil.putData(curator, observerPath, serializedObservers, CuratorUtil.NodeExistsPolicy.OVERWRITE); }
/** * Creates a curator built using Application's zookeeper connection string. Root path will start * at Fluo application chroot. */ public static CuratorFramework newAppCurator(FluoConfiguration config) { return newCurator(config.getAppZookeepers(), config.getZookeeperTimeout()); }
try (CuratorFramework curator = CuratorUtil.newAppCurator(config)) { curator.start();
CuratorUtil.putData(rootCurator, appRootDir, new byte[0], CuratorUtil.NodeExistsPolicy.FAIL); CuratorUtil.putData(curator, ZookeeperPath.CONFIG, new byte[0], CuratorUtil.NodeExistsPolicy.FAIL); CuratorUtil.putData(curator, ZookeeperPath.CONFIG_ACCUMULO_TABLE, config.getAccumuloTable() .getBytes("UTF-8"), CuratorUtil.NodeExistsPolicy.FAIL); CuratorUtil.putData(curator, ZookeeperPath.CONFIG_ACCUMULO_INSTANCE_NAME, accumuloInstanceName.getBytes("UTF-8"), CuratorUtil.NodeExistsPolicy.FAIL); CuratorUtil.putData(curator, ZookeeperPath.CONFIG_ACCUMULO_INSTANCE_ID, accumuloInstanceID.getBytes("UTF-8"), CuratorUtil.NodeExistsPolicy.FAIL); CuratorUtil.putData(curator, ZookeeperPath.CONFIG_FLUO_APPLICATION_ID, fluoApplicationID.getBytes("UTF-8"), CuratorUtil.NodeExistsPolicy.FAIL); CuratorUtil.putData(curator, ZookeeperPath.ORACLE_SERVER, new byte[0], CuratorUtil.NodeExistsPolicy.FAIL); CuratorUtil.putData(curator, ZookeeperPath.ORACLE_MAX_TIMESTAMP, new byte[] {'2'}, CuratorUtil.NodeExistsPolicy.FAIL); CuratorUtil.putData(curator, ZookeeperPath.ORACLE_GC_TIMESTAMP, new byte[] {'0'}, CuratorUtil.NodeExistsPolicy.FAIL);
/** * Creates a curator built using Fluo's zookeeper connection string. Root path will start at root * "/" of Zookeeper. */ public static CuratorFramework newRootFluoCurator(FluoConfiguration config) { return newCurator(ZookeeperUtil.parseServers(config.getInstanceZookeepers()), config.getZookeeperTimeout()); }
public synchronized void start() throws Exception { if (started) { throw new IllegalStateException(); } final InetSocketAddress addr = startServer(); curatorFramework = CuratorUtil.newAppCurator(env.getConfiguration()); curatorFramework.getConnectionStateListenable().addListener(cnxnListener); curatorFramework.start(); while (!cnxnListener.isConnected()) { Thread.sleep(200); } leaderSelector = new LeaderSelector(curatorFramework, ZookeeperPath.ORACLE_SERVER, this); String leaderId = HostUtil.getHostName() + ":" + addr.getPort(); leaderSelector.setId(leaderId); log.info("Leader ID = " + leaderId); leaderSelector.start(); pathChildrenCache = new PathChildrenCache(curatorFramework, oraclePath, true); pathChildrenCache.getListenable().addListener(this); pathChildrenCache.start(); while (!cnxnListener.isConnected()) { Thread.sleep(200); } log.info("Listening " + addr); started = true; }
CuratorUtil.putData(getAppCurator(config), ZookeeperPath.YARN_TWILL_ID, twillId.getBytes(StandardCharsets.UTF_8), CuratorUtil.NodeExistsPolicy.OVERWRITE); CuratorUtil.putData(getAppCurator(config), ZookeeperPath.YARN_APP_ID, appId.getBytes(StandardCharsets.UTF_8), CuratorUtil.NodeExistsPolicy.OVERWRITE);
curatorFramework = CuratorUtil.newAppCurator(env.getConfiguration()); CuratorCnxnListener cnxnListener = new CuratorCnxnListener(); curatorFramework.getConnectionStateListenable().addListener(cnxnListener);
public SharedResources(Environment env) throws TableNotFoundException { this.env = env; curator = CuratorUtil.newAppCurator(env.getConfiguration()); curator.start(); int numTservers = env.getConnector().instanceOperations().getTabletServers().size(); int numBWThreads = FluoConfigurationImpl.getNumBWThreads(env.getConfiguration(), numTservers); bw = env.getConnector().createBatchWriter(env.getTable(), new BatchWriterConfig().setMaxWriteThreads(numBWThreads)); sbw = new SharedBatchWriter(bw); int numCWThreads = FluoConfigurationImpl.getNumCWThreads(env.getConfiguration(), numTservers); cw = env.getConnector().createConditionalWriter( env.getTable(), new ConditionalWriterConfig().setAuthorizations(env.getAuthorizations()) .setMaxWriteThreads(numCWThreads)); bulkCw = env.getConnector().createConditionalWriter( env.getTable(), new ConditionalWriterConfig().setAuthorizations(env.getAuthorizations()) .setMaxWriteThreads(numCWThreads)); txInfoCache = new TxInfoCache(env); visCache = new VisibilityCache(); metricRegistry = new MetricRegistry(); }