Esempio n. 1
0
 public static void downloadFromMaster(Map conf, String file, String localFile)
     throws AuthorizationException, IOException, TException {
   NimbusClient client = NimbusClient.getConfiguredClient(conf);
   try {
     download(client, file, localFile);
   } finally {
     client.close();
   }
 }
Esempio n. 2
0
 public static void downloadFromHost(
     Map conf, String file, String localFile, String host, int port)
     throws IOException, TException, AuthorizationException {
   NimbusClient client = new NimbusClient(conf, host, port, null);
   try {
     download(client, file, localFile);
   } finally {
     client.close();
   }
 }
Esempio n. 3
0
 public static void downloadFromMaster(Map conf, String file, String localFile)
     throws IOException, TException {
   NimbusClient client = NimbusClient.getConfiguredClient(conf);
   String id = client.getClient().beginFileDownload(file);
   WritableByteChannel out = Channels.newChannel(new FileOutputStream(localFile));
   while (true) {
     ByteBuffer chunk = client.getClient().downloadChunk(id);
     int written = out.write(chunk);
     if (written == 0) break;
   }
   out.close();
 }
Esempio n. 4
0
 private static void download(NimbusClient client, String file, String localFile)
     throws IOException, TException, AuthorizationException {
   WritableByteChannel out = Channels.newChannel(new FileOutputStream(localFile));
   try {
     String id = client.getClient().beginFileDownload(file);
     while (true) {
       ByteBuffer chunk = client.getClient().downloadChunk(id);
       int written = out.write(chunk);
       if (written == 0) break;
     }
   } finally {
     out.close();
   }
 }