Exemple #1
0
 private RequestContext stripFromTransactions(RequestContext context) {
   return new RequestContext(
       context.getEpoch(),
       context.machineId(),
       context.getEventIdentifier(),
       0,
       context.getMasterId(),
       context.getChecksum());
 }
 @Override
 public Response<Void> pushTransaction(RequestContext context, String resourceName, long tx) {
   graphDb
       .getTxIdGenerator()
       .committed(
           graphDb.getXaDataSourceManager().getXaDataSource(resourceName),
           context.getEventIdentifier(),
           tx,
           context.machineId());
   return new Response<Void>(
       null, graphDb.getStoreId(), TransactionStream.EMPTY, ResourceReleaser.NO_OP);
 }
 public Map<Integer, Collection<RequestContext>> getOngoingTransactions() {
   Map<Integer, Collection<RequestContext>> result =
       new HashMap<Integer, Collection<RequestContext>>();
   for (RequestContext context : transactions.keySet().toArray(new RequestContext[0])) {
     Collection<RequestContext> txs = result.get(context.machineId());
     if (txs == null) {
       txs = new ArrayList<RequestContext>();
       result.put(context.machineId(), txs);
     }
     txs.add(context);
   }
   return result;
 }
Exemple #4
0
  public Map<Integer, Collection<RequestContext>> getSlaveInformation() {
    // Which slaves are connected a.t.m?
    Set<Integer> machineIds = new HashSet<>();
    Map<Channel, RequestContext> channels = getConnectedSlaveChannels();
    synchronized (channels) {
      for (RequestContext context : channels.values()) {
        machineIds.add(context.machineId());
      }
    }

    // Insert missing slaves into the map so that all connected slave
    // are in the returned map
    Map<Integer, Collection<RequestContext>> ongoingTransactions =
        ((MasterImpl) getRequestTarget()).getOngoingTransactions();
    for (Integer machineId : machineIds) {
      if (!ongoingTransactions.containsKey(machineId)) {
        ongoingTransactions.put(machineId, Collections.<RequestContext>emptyList());
      }
    }
    return new TreeMap<>(ongoingTransactions);
  }