void setUp() throws Exception { testingCluster = new TestingCluster(1); testingCluster.start(); cf = CuratorFrameworkFactory.builder() .connectString(testingCluster.getConnectString()) .retryPolicy(new ExponentialBackoffRetry(1, 10)) .compressionProvider(new PotentiallyGzippedCompressionProvider(false)) .build(); cf.start(); cf.blockUntilConnected(); cf.create().creatingParentsIfNeeded().forPath(basePath); cf.create().creatingParentsIfNeeded().forPath(tasksPath); }
.connectString(testingCluster.getConnectString()) .retryPolicy(new ExponentialBackoffRetry(1, 10)) .compressionProvider(new PotentiallyGzippedCompressionProvider(false))
.connectString(testingCluster.getConnectString()) .retryPolicy(new ExponentialBackoffRetry(1, 10)) .compressionProvider(new PotentiallyGzippedCompressionProvider(false))
.connectString(testingCluster.getConnectString()) .retryPolicy(new ExponentialBackoffRetry(1, 10)) .compressionProvider(new PotentiallyGzippedCompressionProvider(false))
.connectString(testingCluster.getConnectString()) .retryPolicy(new ExponentialBackoffRetry(1, 10)) .compressionProvider(new PotentiallyGzippedCompressionProvider(true))
@Before public void setUp() throws Exception { Logger rootLogger = LogManager.getRootLogger(); rootLogger.setLevel(Level.INFO); conf = new Configuration(); conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true); conf.setBoolean(YarnConfiguration.CURATOR_LEADER_ELECTOR, true); conf.set(YarnConfiguration.RM_CLUSTER_ID, "cluster1"); conf.set(YarnConfiguration.RM_HA_IDS, RM1_NODE_ID + "," + RM2_NODE_ID); for (String confKey : YarnConfiguration.getServiceAddressConfKeys(conf)) { conf.set(HAUtil.addSuffix(confKey, RM1_NODE_ID), RM1_ADDRESS); conf.set(HAUtil.addSuffix(confKey, RM2_NODE_ID), RM2_ADDRESS); } zkCluster = new TestingCluster(3); conf.set(YarnConfiguration.RM_ZK_ADDRESS, zkCluster.getConnectString()); zkCluster.start(); }
@BeforeClass public static void setup() { testingCluster = new TestingCluster(numberOfServersInTestingCluster); try { testingCluster.start(); testingClusterConnectionString = testingCluster.getConnectString(); // Sometimes useful for manual debugging: // testingClusterConnectionString = "localhost:2181"; RetryPolicy retryPolicy = new RetryNTimes( Config.getIntDefault(Config.ZK_CURATOR_SLEEP_TIME_BETWEEN_RETRIES), Config.getIntDefault(Config.ZK_CURATOR_NUMBER_OF_RETRIES)); CuratorFrameworkFactory.Builder cffBuilder = CuratorFrameworkFactory.builder() .connectString(testingClusterConnectionString) .sessionTimeoutMs(Config.getIntDefault(Config.ZK_SESSION_TIMEOUT)) .connectionTimeoutMs(Config.getIntDefault(Config.ZK_CONNECTION_TIMEOUT)) .retryPolicy(retryPolicy) .defaultData(new byte[0]); zkClient = cffBuilder.build(); zkClient.start(); try { zkClient.blockUntilConnected(); } catch (Exception e) { logger.error("There was an unrecoverable exception during the ZooKeeper session establishment. Aborting.", e); throw new RuntimeException(e); } } catch (Exception e) { logger.error("An exception occurred while trying to start the ZK test cluster!", e); throw new RuntimeException(e); } }