Tabnine Logo
DataCenters.getAll
Code IndexAdd Tabnine to your IDE (free)

How to use
getAll
method
in
com.bazaarvoice.emodb.datacenter.api.DataCenters

Best Java code snippets using com.bazaarvoice.emodb.datacenter.api.DataCenters.getAll (Showing top 9 results out of 315)

origin: com.bazaarvoice.emodb/emodb-cachemgr

  @Override
  public void withEndPoints(Function<Collection<EndPoint>, ?> function) {
    List<EndPoint> endPoints = Lists.newArrayList();
    DataCenter self = _dataCenters.getSelf();
    for (DataCenter dataCenter : _dataCenters.getAll()) {
      if (!dataCenter.equals(self)) {
        final URI adminUri = dataCenter.getAdminUri();
        endPoints.add(new EndPoint() {
          @Override
          public String getAddress() {
            return _endPointAdapter.toEndPointAddress(adminUri);
          }

          @Override
          public boolean isValid() {
            return true;
          }
        });
      }
    }

    function.apply(endPoints);
  }
}
origin: bazaarvoice/emodb

  @Override
  public void withEndPoints(Function<Collection<EndPoint>, ?> function) {
    List<EndPoint> endPoints = Lists.newArrayList();
    DataCenter self = _dataCenters.getSelf();
    for (DataCenter dataCenter : _dataCenters.getAll()) {
      if (!dataCenter.equals(self)) {
        final URI adminUri = dataCenter.getAdminUri();
        endPoints.add(new EndPoint() {
          @Override
          public String getAddress() {
            return _endPointAdapter.toEndPointAddress(adminUri);
          }

          @Override
          public boolean isValid() {
            return true;
          }
        });
      }
    }

    function.apply(endPoints);
  }
}
origin: com.bazaarvoice.emodb/emodb-databus

private void drainDataCenterPartition(String dataCenter, int from, int to, PrintWriter printWriter) {
  Map<String, DataCenter> availableDataCenters = _dataCenters.getAll().stream()
      .filter(dc -> !_dataCenters.getSelf().equals(dc))
      .collect(Collectors.toMap(DataCenter::getName, dc -> dc));
  DataCenter outboundDataCenter = availableDataCenters.get(dataCenter);
  if (outboundDataCenter == null) {
    printWriter.write("Invalid data center, must be one of " + Joiner.on(",").join(availableDataCenters.keySet()));
    return;
  }
  
  if (from < _dataCenterFanoutPartitions) {
    printWriter.write("Cannot drain partition currently in use");
    return;
  }
  if (to >= _dataCenterFanoutPartitions) {
    printWriter.write("Cannot drain to partition not in use");
    return;
  }
  printWriter.write(String.format("Draining %s partition %d to partition %d...\n", dataCenter, from, to));
  _eventStore.move(ChannelNames.getReplicationFanoutChannel(outboundDataCenter, from), ChannelNames.getReplicationFanoutChannel(outboundDataCenter, to));
  printWriter.write("Done!\n");
}
origin: bazaarvoice/emodb

private void drainDataCenterPartition(String dataCenter, int from, int to, PrintWriter printWriter) {
  Map<String, DataCenter> availableDataCenters = _dataCenters.getAll().stream()
      .filter(dc -> !_dataCenters.getSelf().equals(dc))
      .collect(Collectors.toMap(DataCenter::getName, dc -> dc));
  DataCenter outboundDataCenter = availableDataCenters.get(dataCenter);
  if (outboundDataCenter == null) {
    printWriter.write("Invalid data center, must be one of " + Joiner.on(",").join(availableDataCenters.keySet()));
    return;
  }
  
  if (from < _dataCenterFanoutPartitions) {
    printWriter.write("Cannot drain partition currently in use");
    return;
  }
  if (to >= _dataCenterFanoutPartitions) {
    printWriter.write("Cannot drain to partition not in use");
    return;
  }
  printWriter.write(String.format("Draining %s partition %d to partition %d...\n", dataCenter, from, to));
  _eventStore.move(ChannelNames.getReplicationFanoutChannel(outboundDataCenter, from), ChannelNames.getReplicationFanoutChannel(outboundDataCenter, to));
  printWriter.write("Done!\n");
}
origin: bazaarvoice/emodb

@Override
protected void runOneIteration() throws Exception {
  try {
    // Start replication for all new data centers.
    Map<String, Managed> active = Maps.newHashMap(_dataCenterFanout);
    DataCenter self = _dataCenters.getSelf();
    for (DataCenter dataCenter : _dataCenters.getAll()) {
      if (dataCenter.equals(self)) {
        continue;
      }
      Managed fanout = active.remove(dataCenter.getName());
      if (fanout == null) {
        fanout = newInboundReplication(dataCenter);
        try {
          fanout.start();
        } catch (Exception e) {
          _log.error("Unexpected exception starting replication service: {}", dataCenter.getName());
          continue;
        }
        _dataCenterFanout.put(dataCenter.getName(), fanout);
      }
    }
    // If a DataCenter has been removed, stop replicating from it.
    stopAll(active);
  } catch (Throwable t) {
    _log.error("Unexpected exception polling data center changes.", t);
  }
}
origin: com.bazaarvoice.emodb/emodb-databus

@Override
protected void runOneIteration() throws Exception {
  try {
    // Start replication for all new data centers.
    Map<String, Managed> active = Maps.newHashMap(_dataCenterFanout);
    DataCenter self = _dataCenters.getSelf();
    for (DataCenter dataCenter : _dataCenters.getAll()) {
      if (dataCenter.equals(self)) {
        continue;
      }
      Managed fanout = active.remove(dataCenter.getName());
      if (fanout == null) {
        fanout = newInboundReplication(dataCenter);
        try {
          fanout.start();
        } catch (Exception e) {
          _log.error("Unexpected exception starting replication service: {}", dataCenter.getName());
          continue;
        }
        _dataCenterFanout.put(dataCenter.getName(), fanout);
      }
    }
    // If a DataCenter has been removed, stop replicating from it.
    stopAll(active);
  } catch (Throwable t) {
    _log.error("Unexpected exception polling data center changes.", t);
  }
}
origin: bazaarvoice/emodb

@Provides
@Singleton
@AllCompactionControlSources
public List<CompactionControlSource> getAllCompactionControlSources(@LocalCompactionControl CompactionControlSource localCompactionControlSource, @ServerCluster String serverCluster,
                                  Client client, DataCenters dataCenters, @CompControlApiKey String compControlApiKey,
                                  HealthCheckRegistry healthCheckRegistry, MetricRegistry metrics) {
  List<CompactionControlSource> compactionControlSources = Lists.newArrayList();
  for (DataCenter dataCenter : dataCenters.getAll()) {
    MultiThreadedServiceFactory<CompactionControlSource> clientFactory = new CompactionControlClientFactory(serverCluster, new JerseyEmoClient(client), compControlApiKey);
    if (dataCenter.equals(dataCenters.getSelf())) {
      compactionControlSources.add(localCompactionControlSource);
    } else {
      ServiceEndPoint endPoint = new ServiceEndPointBuilder()
          .withServiceName(clientFactory.getServiceName())
          .withId(dataCenter.getName())
          .withPayload(new PayloadBuilder()
              .withUrl(dataCenter.getServiceUri().resolve(DataStoreClient.SERVICE_PATH))
              .withAdminUrl(dataCenter.getAdminUri())
              .toString())
          .build();
      compactionControlSources.add(ServicePoolBuilder.create(CompactionControlSource.class)
          .withHostDiscovery(new FixedHostDiscovery(endPoint))
          .withServiceFactory(clientFactory)
          .withCachingPolicy(ServiceCachingPolicyBuilder.getMultiThreadedClientPolicy())
          .withMetricRegistry(metrics)
          .buildProxy(new ExponentialBackoffRetry(30, 1, 10, TimeUnit.SECONDS)));
    }
  }
  return compactionControlSources;
}
origin: com.bazaarvoice.emodb/emodb-databus

private void pollQueueSizes() {
  _gauges.beginUpdates();
  long totalMasterQueueSize = 0;
  for (int partition = 0; partition < _masterFanoutPartitions; partition++) {
    totalMasterQueueSize += pollQueueSize("master-" + partition, ChannelNames.getMasterFanoutChannel(partition));
  }
  _gauges.gauge(newMetric("master")).set(totalMasterQueueSize);
  for (ClusterInfo cluster : _clusterInfo) {
    pollQueueSize("canary-" + cluster.getClusterMetric(), ChannelNames.getMasterCanarySubscription(cluster.getCluster()));
  }
  DataCenter self = _dataCenters.getSelf();
  for (DataCenter dataCenter : _dataCenters.getAll()) {
    if (!dataCenter.equals(self)) {
      long totalDataCenterQueueSize = 0;
      for (int partition = 0; partition < _dataCenterFanoutPartitions; partition++) {
        totalDataCenterQueueSize += pollQueueSize("out-" + dataCenter.getName() + "-" + partition,
            ChannelNames.getReplicationFanoutChannel(dataCenter, partition));
      }
      _gauges.gauge(newMetric("out-" + dataCenter.getName())).set(totalDataCenterQueueSize);
    }
  }
  _gauges.endUpdates();
}
origin: bazaarvoice/emodb

private void pollQueueSizes() {
  _gauges.beginUpdates();
  long totalMasterQueueSize = 0;
  for (int partition = 0; partition < _masterFanoutPartitions; partition++) {
    totalMasterQueueSize += pollQueueSize("master-" + partition, ChannelNames.getMasterFanoutChannel(partition));
  }
  _gauges.gauge(newMetric("master")).set(totalMasterQueueSize);
  for (ClusterInfo cluster : _clusterInfo) {
    pollQueueSize("canary-" + cluster.getClusterMetric(), ChannelNames.getMasterCanarySubscription(cluster.getCluster()));
  }
  DataCenter self = _dataCenters.getSelf();
  for (DataCenter dataCenter : _dataCenters.getAll()) {
    if (!dataCenter.equals(self)) {
      long totalDataCenterQueueSize = 0;
      for (int partition = 0; partition < _dataCenterFanoutPartitions; partition++) {
        totalDataCenterQueueSize += pollQueueSize("out-" + dataCenter.getName() + "-" + partition,
            ChannelNames.getReplicationFanoutChannel(dataCenter, partition));
      }
      _gauges.gauge(newMetric("out-" + dataCenter.getName())).set(totalDataCenterQueueSize);
    }
  }
  _gauges.endUpdates();
}
com.bazaarvoice.emodb.datacenter.apiDataCentersgetAll

Javadoc

Returns all known data centers.

Popular methods of DataCenters

  • getSelf
    Returns the current data center.
  • getForKeyspace
  • refresh
    Reload the set of data centers now. This is rarely necessary since it's refreshed automatically ever

Popular in Java

  • Reactive rest calls using spring rest template
  • setRequestProperty (URLConnection)
  • onRequestPermissionsResult (Fragment)
  • getSystemService (Context)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Collectors (java.util.stream)
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now