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

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

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

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: bazaarvoice/emodb

  @Override
  public Collection<DataCenter> getDataCenters(String placement) {
    String keyspace = PlacementUtil.parsePlacement(placement)[0];
    return _dataCenters.getForKeyspace(keyspace);
  }
}
origin: com.bazaarvoice.emodb/emodb-datacenter

@Override
public void start() throws Exception {
  Set<String> cassandraKeyspaces = Sets.newTreeSet();
  for (KeyspaceDiscovery keyspaceDiscovery : _keyspaceDiscoveries) {
    cassandraKeyspaces.addAll(keyspaceDiscovery.getKeyspacesForDataCenter(_selfCassandraDataCenter));
  }
  boolean system = _selfDataCenter.equals(_systemDataCenter);
  DataCenter self = new DefaultDataCenter(_selfDataCenter, _selfServiceUri, _selfAdminUri, system,
      _selfCassandraDataCenter, cassandraKeyspaces);
  DataCenter original;
  try {
    original = _dataCenters.getSelf();
  } catch (Exception e) {
    original = null;  // self hasn't been announced yet.
  }
  if (_dataCenterDao.saveIfChanged(self, original)) {
    _log.info("Announced new data center: {}", self);
    _dataCenters.refresh();
  }
}
origin: bazaarvoice/emodb

  @Override
  public String get() {
    return format(JOBS_TABLE_NAME_FORMAT, dataCenters.getSelf().getName().replaceAll("\\s", "_"));
  }
};
origin: com.bazaarvoice.emodb/emodb-job

  @Override
  public String get() {
    return format(JOBS_TABLE_NAME_FORMAT, dataCenters.getSelf().getName().replaceAll("\\s", "_"));
  }
};
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

private void cleanupScan(String id) {
  // Remove this scan from the active set
  if (_activeScans.remove(id)) {
    notifyActiveScanCountChanged();
  }
  try {
    // Remove the table snapshots set for this scan
    _dataTools.clearStashTokenRangeSnapshot(id);
  } catch (Exception e) {
    _log.error("Failed to clean up table set for scan {}", id, e);
  }
  try {
    // Delete the entry of the scan start time in Zookeeper.
    _compactionControlSource.deleteStashTime(id, _dataCenters.getSelf().getName());
  } catch (Exception e) {
    _log.error("Failed to delete the stash time for scan {}", id, e);
  }
}
origin: bazaarvoice/emodb

@Override
public void start() throws Exception {
  Set<String> cassandraKeyspaces = Sets.newTreeSet();
  for (KeyspaceDiscovery keyspaceDiscovery : _keyspaceDiscoveries) {
    cassandraKeyspaces.addAll(keyspaceDiscovery.getKeyspacesForDataCenter(_selfCassandraDataCenter));
  }
  boolean system = _selfDataCenter.equals(_systemDataCenter);
  DataCenter self = new DefaultDataCenter(_selfDataCenter, _selfServiceUri, _selfAdminUri, system,
      _selfCassandraDataCenter, cassandraKeyspaces);
  DataCenter original;
  try {
    original = _dataCenters.getSelf();
  } catch (Exception e) {
    original = null;  // self hasn't been announced yet.
  }
  if (_dataCenterDao.saveIfChanged(self, original)) {
    _log.info("Announced new data center: {}", self);
    _dataCenters.refresh();
  }
}
origin: com.bazaarvoice.emodb/emodb-sor

@Override
public Collection<DataCenter> getDataCenters(String placement) {
  String keyspace = PlacementUtil.parsePlacement(placement)[0];
  return _dataCenters.getForKeyspace(keyspace);
}
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

  public void cancel(String id) {
    _scanStatusDAO.setCanceled(id);

    // Notify the workflow the scan status was updated
    _scanWorkflow.scanStatusUpdated(id);

    try {
      // Delete the entry of the scan start time in Zookeeper.
      _compactionControlSource.deleteStashTime(id, _dataCenters.getSelf().getName());
    } catch (Exception e) {
      _log.error("Failed to delete the stash time for scan {}", id, e);
    }
  }
}
origin: bazaarvoice/emodb

@Override
public Collection<DataCenter> getDataCenters(String placement) {
  String keyspace = PlacementUtil.parsePlacement(placement)[0];
  return _dataCenters.getForKeyspace(keyspace);
}
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
public Managed newInboundReplicationFanout(DataCenter dataCenter, ReplicationSource replicationSource) {
  PartitionEventSourceSupplier eventSourceSupplier = partition ->
      new ReplicationEventSource(replicationSource, ChannelNames.getReplicationFanoutChannel(_dataCenters.getSelf(), partition));
  return create("in-" + dataCenter.getName(), eventSourceSupplier, null, REMOTE_DC_SLEEP_WHEN_IDLE, _dataCenterFanoutPartitions);
}
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
public Managed newInboundReplicationFanout(DataCenter dataCenter, ReplicationSource replicationSource) {
  PartitionEventSourceSupplier eventSourceSupplier = partition ->
      new ReplicationEventSource(replicationSource, ChannelNames.getReplicationFanoutChannel(_dataCenters.getSelf(), partition));
  return create("in-" + dataCenter.getName(), eventSourceSupplier, null, REMOTE_DC_SLEEP_WHEN_IDLE, _dataCenterFanoutPartitions);
}
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

  _compactionControlSource.updateStashTime(scanId, compactionControlTime, Lists.newArrayList(status.getOptions().getPlacements()), expireTime, _dataCenters.getSelf().getName());
} catch (Exception e) {
  _log.error("Failed to update the stash time for scan {}", scanId, e);
      _compactionControlSource.deleteStashTime(scanId, _dataCenters.getSelf().getName());
    } catch (Exception ex) {
      _log.error("Failed to delete the stash time for scan {}", scanId, ex);
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-table

public void clearTokenRanges(String stashId) {
  ensureStashTokenRangeTableExists();
  _placementCache.get(_systemTablePlacement)
      .getKeyspace()
      .getCqlSession()
      .execute(
          QueryBuilder.delete()
              .from(STASH_TOKEN_RANGE_TABLE)
              .where(QueryBuilder.eq(STASH_ID_COLUMN, stashId))
              .and(QueryBuilder.eq(DATA_CENTER_COLUMN, _dataCenters.getSelf().getName()))
              .setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM));
}
com.bazaarvoice.emodb.datacenter.apiDataCenters

Most used methods

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

Popular in Java

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • addToBackStack (FragmentTransaction)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • IsNull (org.hamcrest.core)
    Is the value null?
  • 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