Search in sources :

Example 1 with SerializableSerializer

use of org.I0Itec.zkclient.serialize.SerializableSerializer in project curator by Netflix.

the class ZkClientSerializationTest method testSerializables.

@Test
public void testSerializables() throws Exception {
    ZkClient zkClient = ZkTestSystem.createZkClient(_zk.getZkServerAddress());
    zkClient.setZkSerializer(new SerializableSerializer());
    String data = "hello world";
    zkClient.createPersistent("/a", data);
    String readData = zkClient.readData("/a");
    assertEquals(data, readData);
}
Also used : SerializableSerializer(org.I0Itec.zkclient.serialize.SerializableSerializer) Test(org.junit.Test)

Example 2 with SerializableSerializer

use of org.I0Itec.zkclient.serialize.SerializableSerializer in project nutzboot by nutzam.

the class ZkClientStarter method getZkSerializer.

public ZkSerializer getZkSerializer() {
    ZkSerializer serializer = null;
    String zkSerializer = conf.get(PROP_SERIALIZER);
    if (!Strings.isBlank(zkSerializer)) {
        serializer = ioc.get(ZkSerializer.class, zkSerializer);
    }
    if (serializer == null) {
        serializer = new SerializableSerializer();
    }
    return serializer;
}
Also used : SerializableSerializer(org.I0Itec.zkclient.serialize.SerializableSerializer) ZkSerializer(org.I0Itec.zkclient.serialize.ZkSerializer)

Example 3 with SerializableSerializer

use of org.I0Itec.zkclient.serialize.SerializableSerializer in project elephant by yanghuijava.

the class ZkClientRegisterCenter method init.

@Override
public void init() {
    this.zkClient = new ZkClient(this.zkAddress, this.zkSessionTimeOut, this.zkConnectionTimeOut, new SerializableSerializer());
    initRootPath();
    this.zkClient.subscribeStateChanges(new IZkStateListener() {

        @Override
        public void handleStateChanged(KeeperState state) throws Exception {
            if (zkReconnectionListener != null && state.name().equals(KeeperState.SyncConnected.name())) {
                zkReconnectionListener.handleStateForSyncConnected();
            }
        }

        @Override
        public void handleSessionEstablishmentError(Throwable error) throws Exception {
            log.error("处理会话建立错误:{}", error);
        }

        @Override
        public void handleNewSession() throws Exception {
            log.info("会话建立成功!");
        }
    });
}
Also used : ZkClient(org.I0Itec.zkclient.ZkClient) IZkStateListener(org.I0Itec.zkclient.IZkStateListener) SerializableSerializer(org.I0Itec.zkclient.serialize.SerializableSerializer) KeeperState(org.apache.zookeeper.Watcher.Event.KeeperState)

Example 4 with SerializableSerializer

use of org.I0Itec.zkclient.serialize.SerializableSerializer in project helix by apache.

the class TestZkHelixPropertyStore method testZkClientMonitor.

@Test
public void testZkClientMonitor() throws JMException {
    final String TEST_ROOT = "/test_root";
    ZkHelixPropertyStore<ZNRecord> store = new ZkHelixPropertyStore<ZNRecord>(ZK_ADDR, new SerializableSerializer(), TEST_ROOT);
    ObjectName name = MBeanRegistrar.buildObjectName(MonitorDomainNames.HelixZkClient.name(), ZkClientMonitor.MONITOR_TYPE, ZkHelixPropertyStore.MONITOR_TYPE, ZkClientMonitor.MONITOR_KEY, TEST_ROOT, ZkClientPathMonitor.MONITOR_PATH, "Root");
    MBeanServer beanServer = ManagementFactory.getPlatformMBeanServer();
    Assert.assertTrue(beanServer.isRegistered(name));
    store.getStat("/", AccessOption.PERSISTENT);
    Assert.assertEquals((long) beanServer.getAttribute(name, "ReadCounter"), 1);
}
Also used : SerializableSerializer(org.I0Itec.zkclient.serialize.SerializableSerializer) ZNRecord(org.apache.helix.ZNRecord) ObjectName(javax.management.ObjectName) MBeanServer(javax.management.MBeanServer) Test(org.testng.annotations.Test)

Aggregations

SerializableSerializer (org.I0Itec.zkclient.serialize.SerializableSerializer)4 MBeanServer (javax.management.MBeanServer)1 ObjectName (javax.management.ObjectName)1 IZkStateListener (org.I0Itec.zkclient.IZkStateListener)1 ZkClient (org.I0Itec.zkclient.ZkClient)1 ZkSerializer (org.I0Itec.zkclient.serialize.ZkSerializer)1 ZNRecord (org.apache.helix.ZNRecord)1 KeeperState (org.apache.zookeeper.Watcher.Event.KeeperState)1 Test (org.junit.Test)1 Test (org.testng.annotations.Test)1