public static void main(String[] args)
      throws IoTDBConnectionException,
          StatementExecutionException,
          ExecutionException,
          InterruptedException {

    // the thread used for dataMigration must be smaller than session pool size
    ExecutorService executorService = Executors.newFixedThreadPool(CONCURRENCY);

    String path = "root.**";

    if (args.length != 0) {
      path = args[0];
    }

    readerPool = new SessionPool("127.0.0.1", 6667, "root", "root", CONCURRENCY);
    writerPool = new SessionPool("127.0.0.1", 6668, "root", "root", CONCURRENCY);

    SessionDataSetWrapper deviceDataSet = readerPool.executeQueryStatement("count devices " + path);
    DataIterator deviceIter = deviceDataSet.iterator();
    int total;
    if (deviceIter.next()) {
      total = deviceIter.getInt(1);
      LOGGER.info("Total devices: {}", total);
    } else {
      LOGGER.error("Can not get devices schema");
      System.exit(1);
    }
    readerPool.closeResultSet(deviceDataSet);

    deviceDataSet = readerPool.executeQueryStatement("show devices " + path);
    deviceIter = deviceDataSet.iterator();

    List<Future<Void>> futureList = new ArrayList<>();
    int count = 0;
    while (deviceIter.next()) {
      count++;
      Future<Void> future =
          executorService.submit(new LoadThread(count, deviceIter.getString("Device")));
      futureList.add(future);
    }
    readerPool.closeResultSet(deviceDataSet);

    for (Future<Void> future : futureList) {
      future.get();
    }
    executorService.shutdown();

    readerPool.close();
    writerPool.close();
  }
Migrate all data belongs to a path from one IoTDB to another IoTDB Each thread migrate one
series, the concurrent thread can be configured by CONCURRENCY

<p>This example is migrating all timeseries from a local IoTDB with 6667 port to a local IoTDB
with 6668 port
example/session/src/main/java/org/apache/iotdb/DataMigrationExample.java