Java Code Examples for org.apache.hadoop.ipc.RPC#stopProxy()

The following examples show how to use org.apache.hadoop.ipc.RPC#stopProxy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestInterDatanodeProtocol.java    From big-c with Apache License 2.0 6 votes vote down vote up
/** Test to verify that InterDatanode RPC timesout as expected when
 *  the server DN does not respond.
 */
@Test(expected=SocketTimeoutException.class)
public void testInterDNProtocolTimeout() throws Throwable {
  final Server server = new TestServer(1, true);
  server.start();

  final InetSocketAddress addr = NetUtils.getConnectAddress(server);
  DatanodeID fakeDnId = DFSTestUtil.getLocalDatanodeID(addr.getPort());
  DatanodeInfo dInfo = new DatanodeInfo(fakeDnId);
  InterDatanodeProtocol proxy = null;

  try {
    proxy = DataNode.createInterDataNodeProtocolProxy(
        dInfo, conf, 500, false);
    proxy.initReplicaRecovery(new RecoveringBlock(
        new ExtendedBlock("bpid", 1), null, 100));
    fail ("Expected SocketTimeoutException exception, but did not get.");
  } finally {
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
    server.stop();
  }
}
 
Example 2
Source File: RMDelegationTokenIdentifier.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void cancel(Token<?> token, Configuration conf) throws IOException,
    InterruptedException {
  final ApplicationClientProtocol rmClient = getRmClient(token, conf);
  if (rmClient != null) {
    try {
      CancelDelegationTokenRequest request =
          Records.newRecord(CancelDelegationTokenRequest.class);
      request.setDelegationToken(convertToProtoToken(token));
      rmClient.cancelDelegationToken(request);
    } catch (YarnException e) {
      throw new IOException(e);
    } finally {
      RPC.stopProxy(rmClient);
    }
  } else {
    localSecretManager.cancelToken(
        (Token<RMDelegationTokenIdentifier>)token, getRenewer(token));
  }
}
 
Example 3
Source File: DFSClient.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Close the file system, abandoning all of the leases and files being
 * created and close connections to the namenode.
 */
public synchronized void close() throws IOException {
  if(clientRunning) {
    leasechecker.close();
    leasechecker.closeRenewal();
    clientRunning = false;
    try {
      leasechecker.interruptAndJoin();
    } catch (InterruptedException ie) {
    }

    // close connections to the namenode
    RPC.stopProxy(rpcNamenode);
  }
}
 
Example 4
Source File: OMFailoverProxyProvider.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
/**
 * Close all the proxy objects which have been opened over the lifetime of
 * the proxy provider.
 */
@Override
public synchronized void close() throws IOException {
  for (ProxyInfo<OzoneManagerProtocolPB> proxy : omProxies.values()) {
    OzoneManagerProtocolPB omProxy = proxy.proxy;
    if (omProxy != null) {
      RPC.stopProxy(omProxy);
    }
  }
}
 
Example 5
Source File: TestSCMAdminProtocolService.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@After
public void cleanUpTest() {
  if (service != null) {
    service.stop();
  }

  if (SCMAdminProxy != null) {
    RPC.stopProxy(SCMAdminProxy);
  }
}
 
Example 6
Source File: ConfiguredRMFailoverProxyProvider.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Close all the proxy objects which have been opened over the lifetime of
 * this proxy provider.
 */
@Override
public synchronized void close() throws IOException {
  for (T proxy : proxies.values()) {
    if (proxy instanceof Closeable) {
      ((Closeable)proxy).close();
    } else {
      RPC.stopProxy(proxy);
    }
  }
}
 
Example 7
Source File: TestDoAsEffectiveUser.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testRealUserGroupNotSpecified() throws IOException {
  final Configuration conf = new Configuration();
  configureSuperUserIPAddresses(conf, REAL_USER_SHORT_NAME);
  Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
      .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
      .setNumHandlers(2).setVerbose(false).build();

  try {
    server.start();

    final InetSocketAddress addr = NetUtils.getConnectAddress(server);

    UserGroupInformation realUserUgi = UserGroupInformation
        .createRemoteUser(REAL_USER_NAME);

    UserGroupInformation proxyUserUgi = UserGroupInformation
        .createProxyUserForTesting(PROXY_USER_NAME, realUserUgi, GROUP_NAMES);
    String retVal = proxyUserUgi
        .doAs(new PrivilegedExceptionAction<String>() {
          @Override
          public String run() throws IOException {
            proxy = (TestProtocol) RPC.getProxy(TestProtocol.class,
                TestProtocol.versionID, addr, conf);
            String ret = proxy.aMethod();
            return ret;
          }
        });

    Assert.fail("The RPC must have failed " + retVal);
  } catch (Exception e) {
    e.printStackTrace();
  } finally {
    server.stop();
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
  }
}
 
Example 8
Source File: TestDFSClientRetries.java    From big-c with Apache License 2.0 5 votes vote down vote up
/** Test that timeout occurs when DN does not respond to RPC.
 * Start up a server and ask it to sleep for n seconds. Make an
 * RPC to the server and set rpcTimeout to less than n and ensure
 * that socketTimeoutException is obtained
 */
@Test
public void testClientDNProtocolTimeout() throws IOException {
  final Server server = new TestServer(1, true);
  server.start();

  final InetSocketAddress addr = NetUtils.getConnectAddress(server);
  DatanodeID fakeDnId = DFSTestUtil.getLocalDatanodeID(addr.getPort());
  
  ExtendedBlock b = new ExtendedBlock("fake-pool", new Block(12345L));
  LocatedBlock fakeBlock = new LocatedBlock(b, new DatanodeInfo[0]);

  ClientDatanodeProtocol proxy = null;

  try {
    proxy = DFSUtil.createClientDatanodeProtocolProxy(
        fakeDnId, conf, 500, false, fakeBlock);

    proxy.getReplicaVisibleLength(new ExtendedBlock("bpid", 1));
    fail ("Did not get expected exception: SocketTimeoutException");
  } catch (SocketTimeoutException e) {
    LOG.info("Got the expected Exception: SocketTimeoutException");
  } finally {
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
    server.stop();
  }
}
 
Example 9
Source File: YarnClientImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
protected void serviceStop() throws Exception {
  if (this.rmClient != null) {
    RPC.stopProxy(this.rmClient);
  }
  if (historyServiceEnabled) {
    historyClient.stop();
  }
  if (timelineServiceEnabled) {
    timelineClient.stop();
  }
  super.serviceStop();
}
 
Example 10
Source File: TestDoAsEffectiveUser.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test(timeout=4000)
public void testRealUserAuthorizationSuccess() throws IOException {
  final Configuration conf = new Configuration();
  configureSuperUserIPAddresses(conf, REAL_USER_SHORT_NAME);
  conf.setStrings(DefaultImpersonationProvider.getTestProvider().
          getProxySuperuserGroupConfKey(REAL_USER_SHORT_NAME),
      "group1");
  Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
      .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
      .setNumHandlers(2).setVerbose(false).build();

  refreshConf(conf);
  try {
    server.start();

    UserGroupInformation realUserUgi = UserGroupInformation
        .createRemoteUser(REAL_USER_NAME);
    checkRemoteUgi(server, realUserUgi, conf);

    UserGroupInformation proxyUserUgi = UserGroupInformation
        .createProxyUserForTesting(PROXY_USER_NAME, realUserUgi, GROUP_NAMES);
    checkRemoteUgi(server, proxyUserUgi, conf);
  } catch (Exception e) {
    e.printStackTrace();
    Assert.fail();
  } finally {
    server.stop();
    if (proxy != null) {
      RPC.stopProxy(proxy);
    }
  }
}
 
Example 11
Source File: NodeStatusUpdaterImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
protected void stopRMProxy() {
  if(this.resourceTracker != null) {
    RPC.stopProxy(this.resourceTracker);
  }
}
 
Example 12
Source File: ResourceManagerAdministrationProtocolPBClientImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public void close() {
  if (this.proxy != null) {
    RPC.stopProxy(this.proxy);
  }
}
 
Example 13
Source File: ApplicationClientProtocolPBClientImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public void close() {
  if (this.proxy != null) {
    RPC.stopProxy(this.proxy);
  }
}
 
Example 14
Source File: NamenodeProtocolTranslatorPB.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public void close() {
  RPC.stopProxy(rpcProxy);
}
 
Example 15
Source File: LocalJobRunner.java    From RDFS with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Throwable {
  JobConf defaultConf = new JobConf();
  String host = args[0];
  int port = Integer.parseInt(args[1]);
  InetSocketAddress address = new InetSocketAddress(host, port);
  final TaskAttemptID firstTaskid = TaskAttemptID.forName(args[2]);
  final int SLEEP_LONGER_COUNT = 5;
  int jvmIdInt = Integer.parseInt(args[3]);
  JVMId jvmId = new JVMId(firstTaskid.getJobID(),firstTaskid.isMap(),jvmIdInt);
  TaskUmbilicalProtocol umbilical =
    (TaskUmbilicalProtocol)RPC.getProxy(TaskUmbilicalProtocol.class,
        TaskUmbilicalProtocol.versionID,
        address,
        defaultConf);

  String pid = "NONE";
  JvmContext context = new JvmContext(jvmId, pid);
  Task task = null;
  try {
    JvmTask myTask = umbilical.getTask(context);
    task = myTask.getTask();
    if (myTask.shouldDie() || task == null) {
      LOG.error("Returning from local child");
      System.exit(1);
    }
    JobConf job = new JobConf(task.getJobFile());

    File userLogsDir = TaskLog.getBaseDir(task.getTaskID().toString());
    userLogsDir.mkdirs();
    System.setOut(new PrintStream(new FileOutputStream(
      new File(userLogsDir, "stdout"))));
    System.setErr(new PrintStream(new FileOutputStream(
      new File(userLogsDir, "stderr"))));

    task.setConf(job);

    task.run(job, umbilical); // run the task
  } catch (Exception exception) {
    LOG.error("Got exception " + StringUtils.stringifyException(exception));
    try {
      if (task != null) {
        umbilical.statusUpdate(task.getTaskID(), failedStatus(task));
        // do cleanup for the task
        task.taskCleanup(umbilical);
      }
    } catch (Exception e) {
    }
    System.exit(2);
  } catch (Throwable throwable) {
    LOG.error("Got throwable " + throwable);
    if (task != null) {
      Throwable tCause = throwable.getCause();
      String cause = tCause == null 
                     ? throwable.getMessage() 
                     : StringUtils.stringifyException(tCause);
      umbilical.fatalError(task.getTaskID(), cause);
    }
    System.exit(3);
  } finally {
    RPC.stopProxy(umbilical);
  }
}
 
Example 16
Source File: ApplicationMasterProtocolPBClientImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public void close() {
  if (this.proxy != null) {
    RPC.stopProxy(this.proxy);
  }
}
 
Example 17
Source File: ApplicationHistoryProtocolPBClientImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public void close() throws IOException {
  if (this.proxy != null) {
    RPC.stopProxy(this.proxy);
  }
}
 
Example 18
Source File: JournalProtocolTranslatorPB.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public void close() {
  RPC.stopProxy(rpcProxy);
}
 
Example 19
Source File: RefreshAuthorizationPolicyProtocolClientSideTranslatorPB.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public void close() throws IOException {
  RPC.stopProxy(rpcProxy);
}
 
Example 20
Source File: JournalProtocolTranslatorPB.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public void close() {
  RPC.stopProxy(rpcProxy);
}