Java 类io.vertx.core.net.impl.ServerID 实例源码

项目:vertx-infinispan    文件:DataConverter.java   
public static <T> Object toCachedObject(T t) {
  if (t instanceof ServerID) {
    return new InfinispanServerID((ServerID) t);
  }
  if (t instanceof ClusterNodeInfo) {
    return new InfinispanClusterNodeInfo((ClusterNodeInfo) t);
  }
  if (t instanceof ClusterSerializable) {
    return new InfinispanClusterSerializable((ClusterSerializable) t);
  }
  return t;
}
项目:atomix-vertx    文件:AtomixClusterManager.java   
/**
 * Creates a new Vert.x compatible serializer.
 */
private Serializer createSerializer() {
  return Serializer.using(KryoNamespace.builder()
      .setRegistrationRequired(false)
      .register(KryoNamespaces.BASIC)
      .register(ServerID.class)
      .register(new ClusterSerializableSerializer<>(), ClusterSerializable.class)
      .build());
}
项目:vertx-hazelcast    文件:HazelcastServerID.java   
public static <V> V convertServerID(V val) {
  if (val.getClass() == ServerID.class) {
    ServerID sid = (ServerID)val;
    HazelcastServerID hsid = new HazelcastServerID(sid);
    return (V)hsid;
  } else {
    return val;
  }
}
项目:vertx-hazelcast    文件:HazelcastAsyncMultiMapTest.java   
@Test
public void shouldNotAddToMapCacheIfKeyDoesntAlreadyExist() throws Exception {
  String nonexistentKey = "non-existent-key." + UUID.randomUUID();

  map.get(nonexistentKey, ar -> {
    if (ar.succeeded()) {
      try {
        ChoosableIterable<ServerID> s = ar.result();
        Map<String, ChoosableIterable<ServerID>> cache = getCacheFromMap();

        // System.err.println("CACHE CONTENTS: " + cache);

        // check result
        assertNotNull(s);
        assertTrue(s.isEmpty());

        // check cache
        assertNotNull(cache);
        assertFalse(
            "Map cache should not contain key " + nonexistentKey,
            cache.containsKey(nonexistentKey));

      } catch (Exception e) {
        fail(e.toString());
      } finally {
        testComplete();
      }
    } else {
      fail(ar.cause().toString());
    }
  });

  await();
}
项目:vertx-infinispan    文件:InfinispanClusterNodeInfo.java   
@Override
public InfinispanClusterNodeInfo readObject(ObjectInput input) throws IOException, ClassNotFoundException {
  ClusterNodeInfo clusterNodeInfo = new ClusterNodeInfo(input.readUTF(), new ServerID(input.readInt(), input.readUTF()));
  return new InfinispanClusterNodeInfo(clusterNodeInfo);
}
项目:vertx-infinispan    文件:InfinispanServerID.java   
public InfinispanServerID(ServerID serverID) {
  Objects.requireNonNull(serverID);
  this.serverID = serverID;
}
项目:vertx-infinispan    文件:InfinispanServerID.java   
public ServerID getServerID() {
  return serverID;
}
项目:vertx-infinispan    文件:InfinispanServerID.java   
@Override
public InfinispanServerID readObject(ObjectInput input) throws IOException, ClassNotFoundException {
  ServerID serverID = new ServerID(input.readInt(), input.readUTF());
  return new InfinispanServerID(serverID);
}
项目:vertx-hazelcast    文件:HazelcastServerID.java   
public HazelcastServerID(ServerID serverID) {
  super(serverID.port, serverID.host);
}
项目:vertx-hazelcast    文件:HazelcastClusterNodeInfo.java   
@Override
public void readData(ObjectDataInput dataInput) throws IOException {
  nodeId = dataInput.readUTF();
  serverID = new ServerID(dataInput.readInt(), dataInput.readUTF());
}
项目:vertx-hazelcast    文件:HazelcastAsyncMultiMapTest.java   
@SuppressWarnings("unchecked")
private Map<String, ChoosableIterable<ServerID>> getCacheFromMap() throws Exception {
  Field field = map.getClass().getDeclaredField("cache");
  field.setAccessible(true);
  return (Map<String, ChoosableIterable<ServerID>>) field.get(map);
}