本文整理汇总了Java中org.apache.hadoop.hive.metastore.api.AlreadyExistsException类的典型用法代码示例。如果您正苦于以下问题:Java AlreadyExistsException类的具体用法?Java AlreadyExistsException怎么用?Java AlreadyExistsException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AlreadyExistsException类属于org.apache.hadoop.hive.metastore.api包,在下文中一共展示了AlreadyExistsException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create_table
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; //导入依赖的package包/类
@Test
public void create_table()
throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException, TException {
Table table = new Table();
table.setDbName(DB_P);
Table inboundTable = new Table();
inboundTable.setDbName("inbound");
when(primaryMapping.transformInboundTable(table)).thenReturn(inboundTable);
handler.create_table(table);
verify(primaryMapping).checkWritePermissions(DB_P);
verify(primaryClient).create_table(inboundTable);
}
示例2: create_table_with_environment_context
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; //导入依赖的package包/类
@Test
public void create_table_with_environment_context()
throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException, TException {
EnvironmentContext environmentContext = new EnvironmentContext();
Table table = new Table();
table.setDbName(DB_P);
Table inboundTable = new Table();
inboundTable.setDbName("inbound");
when(primaryMapping.transformInboundTable(table)).thenReturn(inboundTable);
handler.create_table_with_environment_context(table, environmentContext);
verify(primaryMapping).checkWritePermissions(DB_P);
verify(primaryClient).create_table_with_environment_context(inboundTable, environmentContext);
}
示例3: add_partition
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; //导入依赖的package包/类
@Test
public void add_partition() throws InvalidObjectException, AlreadyExistsException, MetaException, TException {
Partition newPartition = new Partition();
newPartition.setDbName(DB_P);
Partition inbound = new Partition();
Partition outbound = new Partition();
when(primaryMapping.transformInboundPartition(newPartition)).thenReturn(inbound);
when(primaryClient.add_partition(inbound)).thenReturn(inbound);
when(primaryMapping.transformOutboundPartition(inbound)).thenReturn(outbound);
Partition result = handler.add_partition(newPartition);
assertThat(result, is(outbound));
verify(primaryMapping).checkWritePermissions(DB_P);
}
示例4: add_partition_with_environment_context
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; //导入依赖的package包/类
@Test
public void add_partition_with_environment_context()
throws InvalidObjectException, AlreadyExistsException, MetaException, TException {
EnvironmentContext environmentContext = new EnvironmentContext();
Partition newPartition = new Partition();
newPartition.setDbName(DB_P);
Partition inbound = new Partition();
Partition outbound = new Partition();
when(primaryMapping.transformInboundPartition(newPartition)).thenReturn(inbound);
when(primaryClient.add_partition_with_environment_context(inbound, environmentContext)).thenReturn(inbound);
when(primaryMapping.transformOutboundPartition(inbound)).thenReturn(outbound);
Partition result = handler.add_partition_with_environment_context(newPartition, environmentContext);
assertThat(result, is(outbound));
verify(primaryMapping).checkWritePermissions(DB_P);
}
示例5: add_partitions
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; //导入依赖的package包/类
@Test
public void add_partitions() throws InvalidObjectException, AlreadyExistsException, MetaException, TException {
Partition newPartition1 = new Partition();
newPartition1.setDbName(DB_P);
Partition newPartition2 = new Partition();
newPartition2.setDbName(DB_P);
List<Partition> inbound = Lists.newArrayList(new Partition());
List<Partition> partitions = Lists.newArrayList(newPartition1, newPartition2);
when(primaryMapping.transformInboundPartitions(partitions)).thenReturn(inbound);
when(primaryClient.add_partitions(inbound)).thenReturn(2);
int result = handler.add_partitions(partitions);
assertThat(result, is(2));
verify(primaryMapping, times(2)).checkWritePermissions(DB_P);
}
示例6: add_partitions_pspec
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; //导入依赖的package包/类
@Test
public void add_partitions_pspec() throws InvalidObjectException, AlreadyExistsException, MetaException, TException {
PartitionSpec newPartitionPSpec1 = new PartitionSpec();
newPartitionPSpec1.setDbName(DB_P);
PartitionSpec newPartitionPspec2 = new PartitionSpec();
newPartitionPspec2.setDbName(DB_P);
List<PartitionSpec> inbound = Lists.newArrayList(new PartitionSpec());
List<PartitionSpec> partitionsPspec = Lists.newArrayList(newPartitionPSpec1, newPartitionPspec2);
when(primaryMapping.transformInboundPartitionSpecs(partitionsPspec)).thenReturn(inbound);
when(primaryClient.add_partitions_pspec(inbound)).thenReturn(2);
int result = handler.add_partitions_pspec(partitionsPspec);
assertThat(result, is(2));
verify(primaryMapping, times(2)).checkWritePermissions(DB_P);
}
示例7: append_partition
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; //导入依赖的package包/类
@Test
public void append_partition() throws InvalidObjectException, AlreadyExistsException, MetaException, TException {
Partition inbound = new Partition();
Partition outbound = new Partition();
List<String> partVals = Lists.newArrayList();
when(primaryMapping.transformInboundDatabaseName(DB_P)).thenReturn("inbound");
when(primaryClient.append_partition("inbound", "table1", partVals)).thenReturn(inbound);
when(primaryMapping.transformOutboundPartition(inbound)).thenReturn(outbound);
Partition result = handler.append_partition(DB_P, "table1", partVals);
assertThat(result, is(outbound));
verify(primaryMapping).checkWritePermissions(DB_P);
}
示例8: add_partitions_req
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; //导入依赖的package包/类
@Test
public void add_partitions_req() throws InvalidObjectException, AlreadyExistsException, MetaException, TException {
Partition newPartition1 = new Partition();
newPartition1.setDbName(DB_P);
Partition newPartition2 = new Partition();
newPartition2.setDbName(DB_P);
List<Partition> partitions = Lists.newArrayList(newPartition1, newPartition2);
AddPartitionsRequest request = new AddPartitionsRequest();
request.setDbName(DB_P);
request.setParts(partitions);
AddPartitionsRequest inbound = new AddPartitionsRequest();
AddPartitionsResult addPartitionResult = new AddPartitionsResult();
AddPartitionsResult outbound = new AddPartitionsResult();
when(primaryMapping.transformInboundAddPartitionsRequest(request)).thenReturn(inbound);
when(primaryClient.add_partitions_req(inbound)).thenReturn(addPartitionResult);
when(primaryMapping.transformOutboundAddPartitionsResult(addPartitionResult)).thenReturn(outbound);
AddPartitionsResult result = handler.add_partitions_req(request);
assertThat(result, is(outbound));
verify(primaryMapping, times(3)).checkWritePermissions(DB_P);
}
示例9: append_partition_with_environment_context
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; //导入依赖的package包/类
@Test
public void append_partition_with_environment_context()
throws InvalidObjectException, AlreadyExistsException, MetaException, TException {
EnvironmentContext environmentContext = new EnvironmentContext();
Partition inbound = new Partition();
Partition outbound = new Partition();
List<String> partVals = Lists.newArrayList();
when(primaryMapping.transformInboundDatabaseName(DB_P)).thenReturn("inbound");
when(primaryClient.append_partition_with_environment_context("inbound", "table1", partVals, environmentContext))
.thenReturn(inbound);
when(primaryMapping.transformOutboundPartition(inbound)).thenReturn(outbound);
Partition result = handler.append_partition_with_environment_context(DB_P, "table1", partVals, environmentContext);
assertThat(result, is(outbound));
verify(primaryMapping).checkWritePermissions(DB_P);
}
示例10: append_partition_by_name
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; //导入依赖的package包/类
@Test
public void append_partition_by_name()
throws InvalidObjectException, AlreadyExistsException, MetaException, TException {
Partition inbound = new Partition();
Partition outbound = new Partition();
when(primaryMapping.transformInboundDatabaseName(DB_P)).thenReturn("inbound");
when(primaryClient.append_partition_by_name("inbound", "table1", "partName")).thenReturn(inbound);
when(primaryMapping.transformOutboundPartition(inbound)).thenReturn(outbound);
Partition result = handler.append_partition_by_name(DB_P, "table1", "partName");
assertThat(result, is(outbound));
verify(primaryMapping).checkWritePermissions(DB_P);
}
示例11: append_partition_by_name_with_environment_context
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; //导入依赖的package包/类
@Test
public void append_partition_by_name_with_environment_context()
throws InvalidObjectException, AlreadyExistsException, MetaException, TException {
EnvironmentContext environmentContext = new EnvironmentContext();
Partition inbound = new Partition();
Partition outbound = new Partition();
when(primaryMapping.transformInboundDatabaseName(DB_P)).thenReturn("inbound");
when(primaryClient.append_partition_by_name_with_environment_context("inbound", "table1", "partName",
environmentContext)).thenReturn(inbound);
when(primaryMapping.transformOutboundPartition(inbound)).thenReturn(outbound);
Partition result = handler.append_partition_by_name_with_environment_context(DB_P, "table1", "partName",
environmentContext);
assertThat(result, is(outbound));
verify(primaryMapping).checkWritePermissions(DB_P);
}
示例12: add_drop_partitions
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; //导入依赖的package包/类
/**
* Adds and drops partitions in one transaction.
*
* @param databaseName database name
* @param tableName table name
* @param addParts list of partitions
* @param dropParts list of partition values
* @param deleteData if true, deletes the data
* @return true if successful
* @throws NoSuchObjectException Exception if table does not exists
* @throws MetaException Exception if
* @throws TException any internal exception
*/
@SuppressWarnings({"checkstyle:methodname"})
public boolean add_drop_partitions(final String databaseName,
final String tableName, final List<Partition> addParts,
final List<List<String>> dropParts, final boolean deleteData)
throws NoSuchObjectException, MetaException, TException {
startFunction("add_drop_partitions : db=" + databaseName + " tbl=" + tableName);
if (addParts.size() == 0 && dropParts.size() == 0) {
return true;
}
for (List<String> partVals : dropParts) {
LOG.info("Drop Partition values:" + partVals);
}
for (Partition part : addParts) {
LOG.info("Add Partition values:" + part);
}
boolean ret = false;
Exception ex = null;
try {
ret = addDropPartitionsCore(getMS(), databaseName, tableName, addParts, dropParts, false, null);
} catch (Exception e) {
ex = e;
if (e instanceof MetaException) {
throw (MetaException) e;
} else if (e instanceof InvalidObjectException) {
throw (InvalidObjectException) e;
} else if (e instanceof AlreadyExistsException) {
throw (AlreadyExistsException) e;
} else if (e instanceof NoSuchObjectException) {
throw (NoSuchObjectException) e;
} else {
throw newMetaException(e);
}
} finally {
endFunction("drop_partitions", ret, ex, tableName);
}
return ret;
}
示例13: startAddPartition
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; //导入依赖的package包/类
private boolean startAddPartition(
final RawStore ms, final Partition part, final boolean ifNotExists) throws MetaException, TException {
MetaStoreUtils.validatePartitionNameCharacters(part.getValues(),
partitionValidationPattern);
final boolean doesExist = ms.doesPartitionExist(
part.getDbName(), part.getTableName(), part.getValues());
if (doesExist && !ifNotExists) {
throw new AlreadyExistsException("Partition already exists: " + part);
}
return !doesExist;
}
示例14: addPartitionsCoreNoTxn
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; //导入依赖的package包/类
private List<Partition> addPartitionsCoreNoTxn(
final RawStore ms, final Table tbl, final List<Partition> parts, final boolean ifNotExists,
final Map<PartValEqWrapper, Boolean> addedPartitions, final List<Partition> existingParts)
throws MetaException, InvalidObjectException, AlreadyExistsException, TException {
logInfo("add_partitions");
final String dbName = tbl.getDbName();
final String tblName = tbl.getTableName();
final List<Partition> result = new ArrayList<Partition>();
for (Partition part : parts) {
if (!part.getTableName().equals(tblName) || !part.getDbName().equals(dbName)) {
throw new MetaException("Partition does not belong to target table "
+ dbName + "." + tblName + ": " + part);
}
final boolean shouldAdd = startAddPartition(ms, part, ifNotExists);
if (!shouldAdd) {
existingParts.add(part);
LOG.info("Not adding partition " + part + " as it already exists");
continue;
}
final boolean madeDir = createLocationForAddedPartition(tbl, part);
if (addedPartitions.put(new PartValEqWrapper(part), madeDir) != null) {
// Technically, for ifNotExists case, we could insert one and discard the other
// because the first one now "exists", but it seems better to report the problem
// upstream as such a command doesn't make sense.
throw new MetaException("Duplicate partitions in the list: " + part);
}
initializeAddedPartition(tbl, part, madeDir);
result.add(part);
}
return result;
}
示例15: add_partition
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; //导入依赖的package包/类
private void add_partition(HiveMetaStoreClient client, Table table,
List<String> vals, String location) throws InvalidObjectException,
AlreadyExistsException, MetaException, TException {
Partition part = new Partition();
part.setDbName(table.getDbName());
part.setTableName(table.getTableName());
part.setValues(vals);
part.setParameters(new HashMap<String, String>());
part.setSd(table.getSd());
part.getSd().setSerdeInfo(table.getSd().getSerdeInfo());
part.getSd().setLocation(table.getSd().getLocation() + location);
client.add_partition(part);
}