Ejemplo n.º 1
0
 @Override
 public void setFloodingProxyWeight(UUID hostId, int weight) {
   try {
     Host h = Await.result(backend.store().get(Host.class, toProto(hostId)), TIMEOUT);
     h = h.toBuilder().setFloodingProxyWeight(weight).build();
     backend.store().update(h);
   } catch (Exception e) {
     throw new RuntimeException("Can't retrieve flooding proxy weight");
   }
 }
Ejemplo n.º 2
0
 @Override
 public List<UUID> getHostIds() {
   try {
     scala.collection.Seq<Host> hosts = Await.result(backend.store().getAll(Host.class), TIMEOUT);
     List<UUID> ids = new ArrayList<>();
     for (Host h : asJavaIterable(hosts)) {
       ids.add(fromProto(h.getId()));
     }
     return ids;
   } catch (Exception e) {
     throw new RuntimeException("Cannot get host ids", e);
   }
 }
Ejemplo n.º 3
0
 @Override
 public void createHost(UUID hostId, String name, InetAddress[] addresses) {
   Host h = Host.newBuilder().setId(toProto(hostId)).setName(name).build();
   backend.store().create(h);
   try {
     Await.result(backend.store().get(h.getClass(), hostId), TIMEOUT);
     backend
         .stateStore()
         .addValue(Host.class, hostId, HostKey(), State.HostState.getDefaultInstance().toString())
         .toBlocking()
         .first();
   } catch (Exception e) {
     throw new RuntimeException("Could not create host", e);
   }
 }