org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB Java Examples

The following examples show how to use org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB. 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: NameNodeProxies.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private static ClientProtocol createNNProxyWithClientProtocol(
    InetSocketAddress address, Configuration conf, UserGroupInformation ugi,
    boolean withRetries, AtomicBoolean fallbackToSimpleAuth)
    throws IOException {
  RPC.setProtocolEngine(conf, ClientNamenodeProtocolPB.class, ProtobufRpcEngine.class);

  final RetryPolicy defaultPolicy = 
      RetryUtils.getDefaultRetryPolicy(
          conf, 
          DFSConfigKeys.DFS_CLIENT_RETRY_POLICY_ENABLED_KEY, 
          DFSConfigKeys.DFS_CLIENT_RETRY_POLICY_ENABLED_DEFAULT, 
          DFSConfigKeys.DFS_CLIENT_RETRY_POLICY_SPEC_KEY,
          DFSConfigKeys.DFS_CLIENT_RETRY_POLICY_SPEC_DEFAULT,
          SafeModeException.class);
  
  final long version = RPC.getProtocolVersion(ClientNamenodeProtocolPB.class);
  ClientNamenodeProtocolPB proxy = RPC.getProtocolProxy(
      ClientNamenodeProtocolPB.class, version, address, ugi, conf,
      NetUtils.getDefaultSocketFactory(conf),
      org.apache.hadoop.ipc.Client.getTimeout(conf), defaultPolicy,
      fallbackToSimpleAuth).getProxy();

  if (withRetries) { // create the proxy with retries

    Map<String, RetryPolicy> methodNameToPolicyMap 
               = new HashMap<String, RetryPolicy>();
  
    ClientProtocol translatorProxy =
      new ClientNamenodeProtocolTranslatorPB(proxy);
    return (ClientProtocol) RetryProxy.create(
        ClientProtocol.class,
        new DefaultFailoverProxyProvider<ClientProtocol>(
            ClientProtocol.class, translatorProxy),
        methodNameToPolicyMap,
        defaultPolicy);
  } else {
    return new ClientNamenodeProtocolTranslatorPB(proxy);
  }
}
 
Example #2
Source File: NameNodeProxies.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static ClientProtocol createNNProxyWithClientProtocol(
    InetSocketAddress address, Configuration conf, UserGroupInformation ugi,
    boolean withRetries, AtomicBoolean fallbackToSimpleAuth)
    throws IOException {
  RPC.setProtocolEngine(conf, ClientNamenodeProtocolPB.class, ProtobufRpcEngine.class);

  final RetryPolicy defaultPolicy = 
      RetryUtils.getDefaultRetryPolicy(
          conf, 
          DFSConfigKeys.DFS_CLIENT_RETRY_POLICY_ENABLED_KEY, 
          DFSConfigKeys.DFS_CLIENT_RETRY_POLICY_ENABLED_DEFAULT, 
          DFSConfigKeys.DFS_CLIENT_RETRY_POLICY_SPEC_KEY,
          DFSConfigKeys.DFS_CLIENT_RETRY_POLICY_SPEC_DEFAULT,
          SafeModeException.class);
  
  final long version = RPC.getProtocolVersion(ClientNamenodeProtocolPB.class);
  ClientNamenodeProtocolPB proxy = RPC.getProtocolProxy(
      ClientNamenodeProtocolPB.class, version, address, ugi, conf,
      NetUtils.getDefaultSocketFactory(conf),
      org.apache.hadoop.ipc.Client.getTimeout(conf), defaultPolicy,
      fallbackToSimpleAuth).getProxy();

  if (withRetries) { // create the proxy with retries

    Map<String, RetryPolicy> methodNameToPolicyMap 
               = new HashMap<String, RetryPolicy>();
  
    ClientProtocol translatorProxy =
      new ClientNamenodeProtocolTranslatorPB(proxy);
    return (ClientProtocol) RetryProxy.create(
        ClientProtocol.class,
        new DefaultFailoverProxyProvider<ClientProtocol>(
            ClientProtocol.class, translatorProxy),
        methodNameToPolicyMap,
        defaultPolicy);
  } else {
    return new ClientNamenodeProtocolTranslatorPB(proxy);
  }
}
 
Example #3
Source File: FileSystemTracerTest.java    From garmadon with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setUpClass() throws IOException, NoSuchFieldException, IllegalAccessException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, URISyntaxException, InstantiationException {
    classLoader = new ByteArrayClassLoader.ChildFirst(FileSystemTracerTest.class.getClassLoader(),
        ClassFileExtraction.of(
            Tracer.class,
            MethodTracer.class,
            FileSystemTracer.class,
            FileSystemTracer.WriteTracer.class,
            FileSystemTracer.ReadTracer.class,
            FileSystemTracer.AddBlockTracer.class,
            FileSystemTracer.ListStatusTracer.class,
            FileSystemTracer.GetContentSummaryTracer.class,
            FileSystemTracer.RenameTracer.class,
            FileSystemTracer.DeleteTracer.class,
            DFSClient.class,
            DFSClient.Conf.class,
            ClientContext.class,
            DistributedFileSystem.class,
            DomainSocketFactory.class,
            DFSInputStream.class,
            DFSOutputStream.class,
            HdfsDataInputStream.class,
            HdfsDataOutputStream.class,
            ClientNamenodeProtocolTranslatorPB.class,
            Class.forName("org.apache.hadoop.hdfs.DFSOpsCountStatistics"),
            Class.forName("org.apache.hadoop.hdfs.BlockReaderLocal"),
            Class.forName(DFSOutputStream.class.getName() + "$Packet"),
            Class.forName(DFSOutputStream.class.getName() + "$DataStreamer"),
            Class.forName(DFSOutputStream.class.getName() + "$DataStreamer$1"),
            Class.forName(DFSOutputStream.class.getName() + "$DataStreamer$2"),
            Class.forName(DFSOutputStream.class.getName() + "$DataStreamer$ResponseProcessor"),
            Class.forName(DistributedFileSystem.class.getName() + "$1"),
            Class.forName(DistributedFileSystem.class.getName() + "$4"),
            Class.forName(DistributedFileSystem.class.getName() + "$7"),
            Class.forName(DistributedFileSystem.class.getName() + "$13"),
            Class.forName(DistributedFileSystem.class.getName() + "$14"),
            Class.forName(DistributedFileSystem.class.getName() + "$16"),
            Class.forName(DistributedFileSystem.class.getName() + "$19"),
            Class.forName("org.apache.hadoop.hdfs.LeaseRenewer"),
            Class.forName("org.apache.hadoop.hdfs.LeaseRenewer$1"),
            Class.forName("org.apache.hadoop.hdfs.LeaseRenewer$Factory"),
            Class.forName("org.apache.hadoop.hdfs.LeaseRenewer$Factory$Key"),
            Class.forName("org.apache.hadoop.fs.Hdfs"),
            HdfsDataOutputStream.class
        ),
        ByteArrayClassLoader.PersistenceHandler.MANIFEST);

    argument = ArgumentCaptor.forClass(DataAccessEventProtos.FsEvent.class);

    eventHandler = mock(BiConsumer.class);

    ReflectionHelper.setField(null, classLoader.loadClass(FileSystemTracer.class.getName()), "eventHandler", eventHandler);
    ReflectionHelper.setField(conf, Configuration.class, "classLoader", classLoader);
    assertThat(ByteBuddyAgent.install(), instanceOf(Instrumentation.class));

    new FileSystemTracer.WriteTracer().installOnByteBuddyAgent();
    new FileSystemTracer.ReadTracer().installOnByteBuddyAgent();
    new FileSystemTracer.ListStatusTracer().installOnByteBuddyAgent();
    new FileSystemTracer.GetContentSummaryTracer().installOnByteBuddyAgent();
    new FileSystemTracer.DeleteTracer().installOnByteBuddyAgent();
    new FileSystemTracer.RenameTracer().installOnByteBuddyAgent();

    // MiniDfsCluster
    File baseDir = new File("./target/hdfs/test").getAbsoluteFile();
    FileUtil.fullyDelete(baseDir);
    conf.set("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem");
    conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, baseDir.getAbsolutePath());
    MiniDFSCluster.Builder builder = new MiniDFSCluster.Builder(conf)
        .simulatedCapacities(new long[] {10240000L});
    hdfsCluster = builder.build();
    hdfsURI = "hdfs://localhost:" + hdfsCluster.getNameNodePort();

    initDFS();
}