org.apache.zookeeper.ClientCnxn Java Examples

The following examples show how to use org.apache.zookeeper.ClientCnxn. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZooKeeperx.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
public void configMutliCluster(ZooKeeper zk) {
    if (_serversList.size() == 1) {
        return;
    }
    String cluster1 = _serversList.get(0);
    try {
        if (_serversList.size() > 1) {
            // 强制的声明accessible
            ReflectionUtils.makeAccessible(clientCnxnField);
            ReflectionUtils.makeAccessible(hostProviderField);
            ReflectionUtils.makeAccessible(serverAddressesField);

            // 添加第二组集群列表
            for (int i = 1; i < _serversList.size(); i++) {
                String cluster = _serversList.get(i);
                // 强制获取zk中的地址信息
                ClientCnxn cnxn = (ClientCnxn) ReflectionUtils.getField(clientCnxnField, zk);
                HostProvider hostProvider = (HostProvider) ReflectionUtils.getField(hostProviderField, cnxn);
                List<InetSocketAddress> serverAddrs = (List<InetSocketAddress>) ReflectionUtils.getField(serverAddressesField,
                    hostProvider);
                // 添加第二组集群列表
                serverAddrs.addAll(new ConnectStringParser(cluster).getServerAddresses());
            }
        }
    } catch (Exception e) {
        try {
            if (zk != null) {
                zk.close();
            }
        } catch (InterruptedException ie) {
            // ignore interrupt
        }
        throw new ZkException("zookeeper_create_error, serveraddrs=" + cluster1, e);
    }

}
 
Example #2
Source File: FluoITBase.java    From rya with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
    Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR);

    // Setup and start the Mini Accumulo.
    cluster = clusterInstance.getCluster();

    // Store a connector to the Mini Accumulo.
    instanceName = cluster.getInstanceName();
    zookeepers = cluster.getZooKeepers();

    final Instance instance = new ZooKeeperInstance(instanceName, zookeepers);
    accumuloConn = instance.getConnector(clusterInstance.getUsername(), new PasswordToken(clusterInstance.getPassword()));
}
 
Example #3
Source File: InferenceExamples.java    From rya with Apache License 2.0 5 votes vote down vote up
public static void setupLogging() {
    final Logger rootLogger = LogManager.getRootLogger();
    final ConsoleAppender ca = (ConsoleAppender) rootLogger.getAppender("stdout");
    ca.setLayout(new PatternLayout("%d{MMM dd yyyy HH:mm:ss} %5p [%t] (%F:%L) - %m%n"));
    rootLogger.setLevel(Level.INFO);
    // Filter out noisy messages from the following classes.
    Logger.getLogger(ClientCnxn.class).setLevel(Level.OFF);
    Logger.getLogger(EmbeddedMongoFactory.class).setLevel(Level.OFF);
}
 
Example #4
Source File: RyaClientExample.java    From rya with Apache License 2.0 5 votes vote down vote up
private static void setupLogging() {
    // Turn off all the loggers and customize how they write to the console.
    final Logger rootLogger = LogManager.getRootLogger();
    rootLogger.setLevel(Level.OFF);
    final ConsoleAppender ca = (ConsoleAppender) rootLogger.getAppender("stdout");
    ca.setLayout(new PatternLayout("%-5p - %m%n"));


    // Turn the logger used by the demo back on.
    log.setLevel(Level.INFO);
    Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR);
}
 
Example #5
Source File: MongoRyaDirectExample.java    From rya with Apache License 2.0 5 votes vote down vote up
public static void setupLogging() {
    final Logger rootLogger = LogManager.getRootLogger();
    rootLogger.setLevel(Level.OFF);
    final ConsoleAppender ca = (ConsoleAppender) rootLogger.getAppender("stdout");
    ca.setLayout(new PatternLayout("%d{MMM dd yyyy HH:mm:ss} %5p [%t] (%F:%L) - %m%n"));
    rootLogger.setLevel(Level.INFO);
    // Filter out noisy messages from the following classes.
    Logger.getLogger(ClientCnxn.class).setLevel(Level.OFF);
    Logger.getLogger(EmbeddedMongoFactory.class).setLevel(Level.OFF);
}
 
Example #6
Source File: FluoITBase.java    From rya with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
    Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR);

    // Setup and start the Mini Accumulo.
    cluster = clusterInstance.getCluster();

    // Store a connector to the Mini Accumulo.
    instanceName = cluster.getInstanceName();
    zookeepers = cluster.getZooKeepers();

    final Instance instance = new ZooKeeperInstance(instanceName, zookeepers);
    accumuloConn = instance.getConnector(clusterInstance.getUsername(), new PasswordToken(clusterInstance.getPassword()));
}
 
Example #7
Source File: ZooKeeperx.java    From canal with Apache License 2.0 5 votes vote down vote up
public void configMutliCluster(ZooKeeper zk) {
    if (_serversList.size() == 1) {
        return;
    }
    String cluster1 = _serversList.get(0);
    try {
        if (_serversList.size() > 1) {
            // 强制的声明accessible
            ReflectionUtils.makeAccessible(clientCnxnField);
            ReflectionUtils.makeAccessible(hostProviderField);
            ReflectionUtils.makeAccessible(serverAddressesField);

            // 添加第二组集群列表
            for (int i = 1; i < _serversList.size(); i++) {
                String cluster = _serversList.get(i);
                // 强制获取zk中的地址信息
                ClientCnxn cnxn = (ClientCnxn) ReflectionUtils.getField(clientCnxnField, zk);
                HostProvider hostProvider = (HostProvider) ReflectionUtils.getField(hostProviderField, cnxn);
                List<InetSocketAddress> serverAddrs = (List<InetSocketAddress>) ReflectionUtils.getField(serverAddressesField,
                    hostProvider);
                // 添加第二组集群列表
                serverAddrs.addAll(new ConnectStringParser(cluster).getServerAddresses());
            }
        }
    } catch (Exception e) {
        try {
            if (zk != null) {
                zk.close();
            }
        } catch (InterruptedException ie) {
            // ignore interrupt
        }
        throw new ZkException("zookeeper_create_error, serveraddrs=" + cluster1, e);
    }

}
 
Example #8
Source File: SolrZooKeeper.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public ClientCnxn getConnection() {
  return cnxn;
}
 
Example #9
Source File: AccumuloITBase.java    From rya with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void killLoudLogs() {
    Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR);
}
 
Example #10
Source File: GeoFunctionsTest.java    From rya with Apache License 2.0 4 votes vote down vote up
@Before
public void before() {
    org.apache.log4j.BasicConfigurator.configure();
    Logger.getRootLogger().setLevel(Level.ERROR);
    Logger.getLogger(ClientCnxn.class).setLevel(Level.OFF);
}
 
Example #11
Source File: QueryBenchmarkRunIT.java    From rya with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {
    // Squash loud logs.
    Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR);

    // Setup the Mini Accumulo Cluster.
    final File miniDataDir = com.google.common.io.Files.createTempDir();
    final MiniAccumuloConfig cfg = new MiniAccumuloConfig( miniDataDir, ACCUMULO_PASSWORD);
    cluster = new MiniAccumuloCluster(cfg);
    cluster.start();

    // Create a Rya Client connected to the Mini Accumulo Cluster.
    final AccumuloConnectionDetails connDetails = new AccumuloConnectionDetails(
            ACCUMULO_USER,
            ACCUMULO_PASSWORD.toCharArray(),
            cluster.getInstanceName(),
            cluster.getZooKeepers());
    final Connector connector = cluster.getConnector(ACCUMULO_USER, ACCUMULO_PASSWORD);
    final RyaClient ryaClient = AccumuloRyaClientFactory.build(connDetails, connector);

    // Install an instance of Rya on the mini cluster.
    installRya(ryaClient);

    // Get a Sail object that is backed by the Rya store that is on the mini cluster.
    final AccumuloRdfConfiguration ryaConf = new AccumuloRdfConfiguration();
    ryaConf.setTablePrefix(RYA_INSTANCE_NAME);
    ryaConf.set(ConfigUtils.CLOUDBASE_USER, ACCUMULO_USER);
    ryaConf.set(ConfigUtils.CLOUDBASE_PASSWORD, ACCUMULO_PASSWORD);
    ryaConf.set(ConfigUtils.CLOUDBASE_ZOOKEEPERS, cluster.getZooKeepers());
    ryaConf.set(ConfigUtils.CLOUDBASE_INSTANCE, cluster.getInstanceName());
    ryaConf.set(ConfigUtils.USE_PCJ, "true");
    ryaConf.set(ConfigUtils.PCJ_STORAGE_TYPE, PrecomputedJoinStorageType.ACCUMULO.toString());
    ryaConf.set(ConfigUtils.PCJ_UPDATER_TYPE, PrecomputedJoinUpdaterType.NO_UPDATE.toString());

    sail = RyaSailFactory.getInstance( ryaConf );

    // Load some data into the cluster that will match the query we're testing against.
    loadTestStatements();

    // Add a PCJ to the application that summarizes the query.
    createTestPCJ(ryaClient);
}
 
Example #12
Source File: PcjTablesIT.java    From rya with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void killLoudLogs() {
    Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR);
}
 
Example #13
Source File: RyaShellAccumuloITBase.java    From rya with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void killLoudLogs() {
    Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR);
}