Search in sources :

Example 66 with CuratorFramework

use of org.apache.curator.framework.CuratorFramework in project metron by apache.

the class ConfigurationsUtils method writeGlobalConfigToZookeeper.

public static void writeGlobalConfigToZookeeper(byte[] globalConfig, String zookeeperUrl) throws Exception {
    try (CuratorFramework client = getClient(zookeeperUrl)) {
        client.start();
        writeGlobalConfigToZookeeper(globalConfig, client);
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework)

Example 67 with CuratorFramework

use of org.apache.curator.framework.CuratorFramework in project metron by apache.

the class ConfigurationsUtils method writeSensorEnrichmentConfigToZookeeper.

public static void writeSensorEnrichmentConfigToZookeeper(String sensorType, byte[] configData, String zookeeperUrl) throws Exception {
    try (CuratorFramework client = getClient(zookeeperUrl)) {
        client.start();
        writeSensorEnrichmentConfigToZookeeper(sensorType, configData, client);
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework)

Example 68 with CuratorFramework

use of org.apache.curator.framework.CuratorFramework in project metron by apache.

the class ConfigurationsUtils method applyConfigPatchToZookeeper.

/**
 * Reads Json data for the specified config type and config name (if applicable) from zookeeper,
 * applies the patch from patchData, and writes it back to Zookeeper in a pretty print format.
 * Patching JSON flattens existing formatting, so this will keep configs readable.
 * Starts up curatorclient based on zookeeperUrl.
 *
 * @param configurationType GLOBAL, PARSER, etc.
 * @param configName e.g. bro, yaf, snort
 * @param patchData a JSON patch in the format specified by RFC 6902
 * @param zookeeperUrl configs are here
 */
public static void applyConfigPatchToZookeeper(ConfigurationType configurationType, Optional<String> configName, byte[] patchData, String zookeeperUrl) throws Exception {
    try (CuratorFramework client = getClient(zookeeperUrl)) {
        client.start();
        applyConfigPatchToZookeeper(configurationType, configName, patchData, client);
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework)

Example 69 with CuratorFramework

use of org.apache.curator.framework.CuratorFramework in project metron by apache.

the class ConfigurationsUtils method writeGlobalConfigToZookeeper.

public static void writeGlobalConfigToZookeeper(Map<String, Object> globalConfig, String zookeeperUrl) throws Exception {
    try (CuratorFramework client = getClient(zookeeperUrl)) {
        client.start();
        writeGlobalConfigToZookeeper(globalConfig, client);
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework)

Example 70 with CuratorFramework

use of org.apache.curator.framework.CuratorFramework in project metron by apache.

the class SensorEnrichmentUpdateConfig method updateSensorConfigs.

public void updateSensorConfigs() throws Exception {
    CuratorFramework client = ConfigurationsUtils.getClient(getZkQuorum());
    try {
        client.start();
        updateSensorConfigs(new ZKSourceConfigHandler(client), sensorToFieldList);
    } finally {
        client.close();
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework)

Aggregations

CuratorFramework (org.apache.curator.framework.CuratorFramework)824 Test (org.testng.annotations.Test)290 RetryOneTime (org.apache.curator.retry.RetryOneTime)267 Test (org.junit.Test)168 Timing (org.apache.curator.test.Timing)147 CountDownLatch (java.util.concurrent.CountDownLatch)120 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)98 KeeperException (org.apache.zookeeper.KeeperException)84 IOException (java.io.IOException)75 ConnectionState (org.apache.curator.framework.state.ConnectionState)70 CuratorEvent (org.apache.curator.framework.api.CuratorEvent)52 ConnectionStateListener (org.apache.curator.framework.state.ConnectionStateListener)50 RetryNTimes (org.apache.curator.retry.RetryNTimes)48 ExecutorService (java.util.concurrent.ExecutorService)47 ArrayList (java.util.ArrayList)44 RetryPolicy (org.apache.curator.RetryPolicy)36 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)35 Stat (org.apache.zookeeper.data.Stat)35 BackgroundCallback (org.apache.curator.framework.api.BackgroundCallback)33 CuratorFrameworkFactory (org.apache.curator.framework.CuratorFrameworkFactory)32