Ejemplo n.º 1
0
 public void addKnownInput(
     String hostName,
     int port,
     InputAttemptIdentifier srcAttemptIdentifier,
     int srcPhysicalIndex) {
   String identifier = InputHost.createIdentifier(hostName, port);
   InputHost host = knownSrcHosts.get(identifier);
   if (host == null) {
     host = new InputHost(hostName, port, inputContext.getApplicationId(), srcPhysicalIndex);
     assert identifier.equals(host.getIdentifier());
     InputHost old = knownSrcHosts.putIfAbsent(identifier, host);
     if (old != null) {
       host = old;
     }
   }
   if (LOG.isDebugEnabled()) {
     LOG.debug("Adding input: " + srcAttemptIdentifier + ", to host: " + host);
   }
   host.addKnownInput(srcAttemptIdentifier);
   lock.lock();
   try {
     boolean added = pendingHosts.offer(host);
     if (!added) {
       String errorMessage = "Unable to add host: " + host.getIdentifier() + " to pending queue";
       LOG.error(errorMessage);
       throw new TezUncheckedException(errorMessage);
     }
     wakeLoop.signal();
   } finally {
     lock.unlock();
   }
 }
Ejemplo n.º 2
0
 @Override
 public void onSuccess(FetchResult result) {
   fetcher.shutdown();
   if (isShutdown.get()) {
     LOG.info("Already shutdown. Ignoring event from fetcher");
   } else {
     Iterable<InputAttemptIdentifier> pendingInputs = result.getPendingInputs();
     if (pendingInputs != null && pendingInputs.iterator().hasNext()) {
       InputHost inputHost =
           knownSrcHosts.get(InputHost.createIdentifier(result.getHost(), result.getPort()));
       assert inputHost != null;
       for (InputAttemptIdentifier input : pendingInputs) {
         inputHost.addKnownInput(input);
       }
       pendingHosts.add(inputHost);
     }
     doBookKeepingForFetcherComplete();
   }
 }