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

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

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

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-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
  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-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: 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 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

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

  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
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

@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
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-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));
}
origin: com.bazaarvoice.emodb/emodb-databus

private Managed create(final String name, final PartitionEventSourceSupplier eventSourceSupplier,
            @Nullable final PartitionSelector outboundPartitionSelector, final Duration sleepWhenIdle,
            final int partitions) {
  final Function<Multimap<String, ByteBuffer>, Void> eventSink = eventsByChannel -> {
    _eventStore.addAll(eventsByChannel);
    return null;
  };
  final Supplier<Iterable<OwnedSubscription>> subscriptionsSupplier = _subscriptionDao::getAllSubscriptions;
  PartitionedLeaderService partitionedLeaderService = new PartitionedLeaderService(
      _curator, ZKPaths.makePath("/leader/fanout", "partitioned-" + name),
      _selfId, "PartitionedLeaderSelector-" + name, partitions, 1,  1, TimeUnit.MINUTES,
      partition -> new DefaultFanout(name, "partition-" + partition,
          eventSourceSupplier.createEventSourceForPartition(partition),
          eventSink, outboundPartitionSelector, sleepWhenIdle, subscriptionsSupplier, _dataCenters.getSelf(),
          _logFactory, _subscriptionEvaluator, _fanoutLagMonitor, _metricRegistry, _clock),
      _clock);
  for (LeaderService leaderService : partitionedLeaderService.getPartitionLeaderServices()) {
    ServiceFailureListener.listenTo(leaderService, _metricRegistry);
  }
  _dropwizardTask.register("databus-fanout-" + name, partitionedLeaderService);
  return partitionedLeaderService;
}
origin: bazaarvoice/emodb

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));
}
origin: bazaarvoice/emodb

private Managed create(final String name, final PartitionEventSourceSupplier eventSourceSupplier,
            @Nullable final PartitionSelector outboundPartitionSelector, final Duration sleepWhenIdle,
            final int partitions) {
  final Function<Multimap<String, ByteBuffer>, Void> eventSink = eventsByChannel -> {
    _eventStore.addAll(eventsByChannel);
    return null;
  };
  final Supplier<Iterable<OwnedSubscription>> subscriptionsSupplier = _subscriptionDao::getAllSubscriptions;
  PartitionedLeaderService partitionedLeaderService = new PartitionedLeaderService(
      _curator, ZKPaths.makePath("/leader/fanout", "partitioned-" + name),
      _selfId, "PartitionedLeaderSelector-" + name, partitions, 1,  1, TimeUnit.MINUTES,
      partition -> new DefaultFanout(name, "partition-" + partition,
          eventSourceSupplier.createEventSourceForPartition(partition),
          eventSink, outboundPartitionSelector, sleepWhenIdle, subscriptionsSupplier, _dataCenters.getSelf(),
          _logFactory, _subscriptionEvaluator, _fanoutLagMonitor, _metricRegistry, _clock),
      _clock);
  for (LeaderService leaderService : partitionedLeaderService.getPartitionLeaderServices()) {
    ServiceFailureListener.listenTo(leaderService, _metricRegistry);
  }
  _dropwizardTask.register("databus-fanout-" + name, partitionedLeaderService);
  return partitionedLeaderService;
}
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();
}
origin: com.bazaarvoice.emodb/emodb-table

private Iterator<ProtoStashTokenRange> getTokenRangesBetweenIntraShard(String stashId, String placement,
                                    ByteBuffer fromInclusive, ByteBuffer toExclusive) {
  // Since the range falls entirely within a single shard run a targeted query that only looks for the beginning
  // of that shard.
  ByteBuffer startToken = RowKeyUtils.getRowKeyRaw(RowKeyUtils.getShardId(fromInclusive), RowKeyUtils.getTableUuid(fromInclusive), new byte[0]);
  ResultSet resultSet = _placementCache.get(_systemTablePlacement)
      .getKeyspace()
      .getCqlSession()
      .execute(
          QueryBuilder.select(TABLE_JSON_COLUMN)
              .from(STASH_TOKEN_RANGE_TABLE)
              .where(QueryBuilder.eq(STASH_ID_COLUMN, stashId))
              .and(QueryBuilder.eq(DATA_CENTER_COLUMN, _dataCenters.getSelf().getName()))
              .and(QueryBuilder.eq(PLACEMENT_COLUMN, placement))
              .and(QueryBuilder.eq(RANGE_TOKEN_COLUMN, startToken))
              .and(QueryBuilder.eq(IS_START_TOKEN_COLUMN, true))
              .limit(1)
              .setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM));
  Row row = resultSet.one();
  if (row == null) {
    return Iterators.emptyIterator();
  }
  TableJson tableJson = toTableJson(row.getString(0));
  return Iterators.singletonIterator(new ProtoStashTokenRange(fromInclusive, toExclusive, tableJson));
}
com.bazaarvoice.emodb.datacenter.apiDataCentersgetSelf

Javadoc

Returns the current data center.

Popular methods of DataCenters

  • 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

  • Parsing JSON documents to java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • compareTo (BigDecimal)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • 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
  • JCheckBox (javax.swing)
  • Top Sublime Text plugins
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