@Override
  public void close() {
    // No more tasks may be submitted after this point.
    singleThreadExecutor.shutdown();
    parallelExecutor.shutdown();
    if (proxy != null) {
      // TODO: this can hang for quite some time if the client
      // is currently in the middle of a call to a downed JN.
      // We should instead do this asynchronously, and just stop
      // making any more calls after this point (eg clear the queue)
      RPC.stopProxy(proxy);
    }
    metrics.unregister();
  }
@Test
  public void testMetricsRemovedOnClose() {
    MetricsSystem metricsSystem = DefaultMetricsSystem.instance();
    String sourceName = "IPCLoggerChannel-"
        + FAKE_ADDR.getAddress().getHostAddress()
        + "-" + FAKE_ADDR.getPort();
    // Ensure the metrics exist
    MetricsSource source = metricsSystem.getSource(sourceName);
    assertNotNull(source);

    ch.close();
    // ensure the metrics are removed.
    source = metricsSystem.getSource(sourceName);
    assertNull(source);
  }