Skip to content

Commit

Permalink
Only update ZooCache via table-config-version when needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzgithub1 committed Nov 15, 2019
1 parent b3cd2e3 commit 8fb054a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -816,26 +816,26 @@ public static void initSystemTablesConfig(ZooReaderWriter zoo, String zooKeeperR
}
for (Entry<String,String> entry : initialMetadataConf.entrySet()) {
if (!TablePropUtil.setTableProperty(zoo, zooKeeperRoot, RootTable.ID, entry.getKey(),
entry.getValue())) {
entry.getValue(), false)) {
throw new IOException("Cannot create per-table property " + entry.getKey());
}
if (!TablePropUtil.setTableProperty(zoo, zooKeeperRoot, MetadataTable.ID, entry.getKey(),
entry.getValue())) {
entry.getValue(), false)) {
throw new IOException("Cannot create per-table property " + entry.getKey());
}
}
// Only add combiner config to accumulo.metadata table (ACCUMULO-3077)
for (Entry<String,String> entry : initialMetadataCombinerConf.entrySet()) {
if (!TablePropUtil.setTableProperty(zoo, zooKeeperRoot, MetadataTable.ID, entry.getKey(),
entry.getValue())) {
entry.getValue(), false)) {
throw new IOException("Cannot create per-table property " + entry.getKey());
}
}

// add configuration to the replication table
for (Entry<String,String> entry : initialReplicationTableConf.entrySet()) {
if (!TablePropUtil.setTableProperty(zoo, zooKeeperRoot, ReplicationTable.ID, entry.getKey(),
entry.getValue())) {
entry.getValue(), false)) {
throw new IOException("Cannot create per-table property " + entry.getKey());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public void cloneTable(TableId srcTableId, TableId tableId, String tableName,
zoo.recursiveCopyPersistent(srcTablePath, newTablePath, NodeExistsPolicy.OVERWRITE);

for (Entry<String,String> entry : propertiesToSet.entrySet())
TablePropUtil.setTableProperty(context, tableId, entry.getKey(), entry.getValue());
TablePropUtil.setTableProperty(context, tableId, entry.getKey(), entry.getValue(), false);

for (String prop : propertiesToExclude)
zoo.recursiveDelete(Constants.ZROOT + "/" + instanceID + Constants.ZTABLES + "/" + tableId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ public class TablePropUtil {
private static final Logger log = LoggerFactory.getLogger(TablePropUtil.class);

public static boolean setTableProperty(ServerContext context, TableId tableId, String property,
String value) throws KeeperException, InterruptedException {
String value, boolean doUpdateTableConfVersion) throws KeeperException, InterruptedException {
return setTableProperty(context.getZooReaderWriter(), context.getZooKeeperRoot(), tableId,
property, value);
property, value, doUpdateTableConfVersion);
}

public static boolean setTableProperty(ZooReaderWriter zoo, String zkRoot, TableId tableId,
String property, String value) throws KeeperException, InterruptedException {
String property, String value, boolean doUpdateTableConfVersion)
throws KeeperException, InterruptedException {
if (!isPropertyValid(property, value))
return false;

Expand All @@ -54,10 +55,14 @@ public static boolean setTableProperty(ZooReaderWriter zoo, String zkRoot, Table
// create the zk node for this property and set it's data to the specified value
String zPath = zkTablePath + "/" + property;
zoo.putPersistentData(zPath, value.getBytes(UTF_8), NodeExistsPolicy.OVERWRITE);
updateTableConfigTrackingZnode(zPath, zoo);
if (log.isTraceEnabled()) {
log.trace("updateTableConfigTrackingZnode called in setTableProperty for " + zPath);

if (doUpdateTableConfVersion) {
updateTableConfigTrackingZnode(zPath, zoo);
if (log.isTraceEnabled()) {
log.trace("updateTableConfigTrackingZnode called in setTableProperty for " + zPath);
}
}

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ private void alterTableProperty(TCredentials c, String tableName, String propert
try {
if (value == null || value.isEmpty()) {
TablePropUtil.removeTableProperty(master.getContext(), tableId, property);
} else if (!TablePropUtil.setTableProperty(master.getContext(), tableId, property, value)) {
} else if (!TablePropUtil.setTableProperty(master.getContext(), tableId, property, value,
true)) {
throw new Exception("Invalid table property.");
}
} catch (KeeperException.NoNodeException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Repo<Master> call(long tid, Master master) throws Exception {

for (Entry<String,String> entry : tableInfo.props.entrySet())
TablePropUtil.setTableProperty(master.getContext(), tableInfo.getTableId(), entry.getKey(),
entry.getValue());
entry.getValue(), false);

Tables.clearCache(master.getContext());
return new ChooseDir(tableInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public Repo<Master> call(long tid, Master env) throws Exception {

for (Entry<String,String> entry : getExportedProps(env.getFileSystem()).entrySet())
if (!TablePropUtil.setTableProperty(env.getContext(), tableInfo.tableId, entry.getKey(),
entry.getValue())) {
entry.getValue(), false)) {
throw new AcceptableThriftTableOperationException(tableInfo.tableId.canonical(),
tableInfo.tableName, TableOperation.IMPORT, TableOperationExceptionType.OTHER,
"Invalid table property " + entry.getKey());
Expand Down

0 comments on commit 8fb054a

Please sign in to comment.