try (HiveMetastoreClientPool.MultiClient multiClient = HiveMetastoreClientPool.safeGetClients(namedPools)) { if (multiClient.getClient(target_client).tableExists(this.targetDatabase, this.dataset.table.getTableName())) { this.existingTargetTable = Optional.of(new Table( multiClient.getClient(target_client).getTable(this.targetDatabase, this.dataset.table.getTableName()))); } else { this.existingTargetTable = Optional.absent(); this.sourcePartitions = HiveUtils.getPartitionsMap(multiClient.getClient(source_client), this.dataset.table, this.partitionFilter, this.hivePartitionExtendedFilter); HiveAvroCopyEntityHelper.updatePartitionAttributesIfAvro(this.targetTable, this.sourcePartitions, this); HiveUtils.getPartitionsMap(multiClient.getClient(target_client), this.existingTargetTable.get(), this.partitionFilter, this.hivePartitionExtendedFilter)) : Maps.<List<String>, Partition> newHashMap();
try (HiveMetastoreClientPool.MultiClient multiClient = HiveMetastoreClientPool.safeGetClients(namedPools)) { if (multiClient.getClient(target_client).tableExists(this.targetDatabase, this.dataset.table.getTableName())) { this.existingTargetTable = Optional.of(new Table( multiClient.getClient(target_client).getTable(this.targetDatabase, this.dataset.table.getTableName()))); } else { this.existingTargetTable = Optional.absent(); this.sourcePartitions = HiveUtils.getPartitionsMap(multiClient.getClient(source_client), this.dataset.table, this.partitionFilter, this.hivePartitionExtendedFilter); HiveAvroCopyEntityHelper.updatePartitionAttributesIfAvro(this.targetTable, this.sourcePartitions, this); HiveUtils.getPartitionsMap(multiClient.getClient(target_client), this.existingTargetTable.get(), this.partitionFilter, this.hivePartitionExtendedFilter)) : Maps.<List<String>, Partition> newHashMap();
/** * A method to get multiple {@link IMetaStoreClient}s while preventing deadlocks. * @param namedPools A map from String to {@link HiveMetastoreClientPool}. * @return a {@link MultiClient} with a {@link IMetaStoreClient} for each entry in the input map. The client can * be retrieved by its name in the input map. * @throws IOException */ public static synchronized MultiClient safeGetClients(Map<String, HiveMetastoreClientPool> namedPools) throws IOException { return new MultiClient(namedPools); }
/** * A method to get multiple {@link IMetaStoreClient}s while preventing deadlocks. * @param namedPools A map from String to {@link HiveMetastoreClientPool}. * @return a {@link MultiClient} with a {@link IMetaStoreClient} for each entry in the input map. The client can * be retrieved by its name in the input map. * @throws IOException */ public static synchronized MultiClient safeGetClients(Map<String, HiveMetastoreClientPool> namedPools) throws IOException { return new MultiClient(namedPools); }