listSize++;
Partition part = msc.getPartition("hive2038", "tmptbl", "b=2011");
assertEquals(notifyList.size(), listSize);
assertEquals(preNotifyList.size(), listSize);
AddPartitionEvent partEvent = (AddPartitionEvent)(notifyList.get(listSize-1));
assert partEvent.getStatus();
validateAddPartition(part, partEvent.getPartitions().get(0));
validateTableInAddPartition(tbl, partEvent.getTable());
PreAddPartitionEvent prePartEvent = (PreAddPartitionEvent)(preNotifyList.get(listSize-1));
validateAddPartition(part, prePartEvent.getPartitions().get(0));
// Test adding multiple partitions in a single partition-set, atomically.
int currentTime = (int)System.currentTimeMillis();
HiveMetaStoreClient hmsClient = new HiveMetaStoreClient(hiveConf);
Table table = hmsClient.getTable(dbName, "tmptbl");
Partition partition1 = new Partition(Arrays.asList("20110101"), dbName, "tmptbl", currentTime,
currentTime, table.getSd(), table.getParameters());
Partition partition2 = new Partition(Arrays.asList("20110102"), dbName, "tmptbl", currentTime,
currentTime, table.getSd(), table.getParameters());
Partition partition3 = new Partition(Arrays.asList("20110103"), dbName, "tmptbl", currentTime,
currentTime, table.getSd(), table.getParameters());
hmsClient.add_partitions(Arrays.asList(partition1, partition2, partition3));
++listSize;
AddPartitionEvent multiplePartitionEvent = (AddPartitionEvent)(notifyList.get(listSize-1));
assertEquals("Unexpected number of partitions in event!", 3, multiplePartitionEvent.getPartitions().size());
assertEquals("Unexpected table value.", table, multiplePartitionEvent.getTable());
assertEquals("Unexpected partition value.", partition1.getValues(), multiplePartitionEvent.getPartitions().get(0).getValues());
assertEquals("Unexpected partition value.", partition2.getValues(), multiplePartitionEvent.getPartitions().get(1).getValues());
assertEquals("Unexpected partition value.", partition3.getValues(), multiplePartitionEvent.getPartitions().get(2).getValues());
driver.run(String.format("alter table %s touch partition (%s)", tblName, "b='2011'"));
listSize++;
assertEquals(notifyList.size(), listSize);
assertEquals(preNotifyList.size(), listSize);
//the partition did not change,
// so the new partition should be similar to the original partition
Partition origP = msc.getPartition(dbName, tblName, "b=2011");
AlterPartitionEvent alterPartEvent = (AlterPartitionEvent)notifyList.get(listSize - 1);
assert alterPartEvent.getStatus();
validateAlterPartition(origP, origP, alterPartEvent.getOldPartition().getDbName(),
alterPartEvent.getOldPartition().getTableName(),
alterPartEvent.getOldPartition().getValues(), alterPartEvent.getNewPartition());
PreAlterPartitionEvent preAlterPartEvent =
(PreAlterPartitionEvent)preNotifyList.get(listSize - 1);
validateAlterPartition(origP, origP, preAlterPartEvent.getDbName(),
preAlterPartEvent.getTableName(), preAlterPartEvent.getNewPartition().getValues(),
preAlterPartEvent.getNewPartition());
List<String> part_vals = new ArrayList<String>();
part_vals.add("c=2012");
Partition newPart = msc.appendPartition(dbName, tblName, part_vals);
listSize++;
assertEquals(notifyList.size(), listSize);
assertEquals(preNotifyList.size(), listSize);
AddPartitionEvent appendPartEvent =
(AddPartitionEvent)(notifyList.get(listSize-1));
validateAddPartition(newPart, appendPartEvent.getPartitions().get(0));
PreAddPartitionEvent preAppendPartEvent =
(PreAddPartitionEvent)(preNotifyList.get(listSize-1));
validateAddPartition(newPart, preAppendPartEvent.getPartitions().get(0));