in odps-console-basic/src/main/java/com/aliyun/openservices/odps/console/commands/SetCommand.java [103:195]
public void run() throws OdpsException, ODPSConsoleException {
if (isSet) {
if (ODPS_INSTANCE_PRIORITY.equalsIgnoreCase(key)) {
try {
getContext().setPriority(Integer.parseInt(value));
getContext().setPaiPriority(Integer.parseInt(value));
} catch (NumberFormatException e) {
throw new ODPSConsoleException(
"priority need int value[odps.instance.priority=" + value + "]");
}
}
if (ODPS_RUNNING_CLUSTER.equalsIgnoreCase(key)) {
getContext().setRunningCluster(value);
}
if (ODPS_SQL_TIMEZONE.equalsIgnoreCase(key)) {
getContext().setSqlTimezone(value);
getContext().setUserSetSqlTimezone(true);
}
if (ENABLE_INTERACTIVE_MODE.equals(key)) {
// change interactive mode temporarily
getContext().setInteractiveQuery(Boolean.parseBoolean(value));
getWriter().writeError("OK");
return;
}
if (key.startsWith(ODPSConsoleConstants.FALLBACK_PREFIX)) {
switch (key) {
case ODPSConsoleConstants.FALLBACK_RESOURCE_NOT_ENOUGH:
getContext().getFallbackPolicy()
.fallback4ResourceNotEnough(Boolean.parseBoolean(value));
break;
case ODPSConsoleConstants.FALLBACK_UNSUPPORTED:
getContext().getFallbackPolicy()
.fallback4UnsupportedFeature(Boolean.parseBoolean(value));
break;
case ODPSConsoleConstants.FALLBACK_UPGRADING:
getContext().getFallbackPolicy().fallback4Upgrading(Boolean.parseBoolean(value));
break;
case ODPSConsoleConstants.FALLBACK_QUERY_TIMEOUT:
getContext().getFallbackPolicy().fallback4RunningTimeout(Boolean.parseBoolean(value));
break;
case ODPSConsoleConstants.FALLBACK_ATTACH_FAILED:
getContext().getFallbackPolicy().fallback4AttachError(Boolean.parseBoolean(value));
break;
case ODPSConsoleConstants.FALLBACK_UNKNOWN:
getContext().getFallbackPolicy().fallback4UnknownError(Boolean.parseBoolean(value));
break;
default:
throw new ODPSConsoleException("unknown fallback policy: " + key);
}
getWriter().writeError("OK");
return;
}
// set query results fetched by instance tunnel or not
if (CONSOLE_SQL_RESULT_INSTANCETUNNEL.equalsIgnoreCase(key)) {
getContext().setUseInstanceTunnel(Boolean.parseBoolean(value));
}
// This flag will also be set by odpscmd itself when users change the project and schema
if (ODPS_DEFAULT_SCHEMA.equalsIgnoreCase(key)) {
if (getContext().isProjectMode()) {
throw new ODPSConsoleException(
"Can't set default schema if odps.namespace.schema is false");
}
if (!getCurrentOdps().schemas().exists(value)) {
throw new ODPSConsoleException(
"schema " + value + " not exists in project " + getCurrentOdps().getDefaultProject());
}
getContext().setSchemaName(value);
}
if (ODPS_NAMESPACE_SCHEMA.equals(key)) {
isBooleanStr(value, key);
getContext().setOdpsNamespaceSchema(Boolean.parseBoolean(value));
}
if (ACL_LIST.contains(key.toUpperCase())) {
setSecurityConfig(key);
} else {
setMap.put(key, value);
}
} else {
// 不能够传递
aliasMap.put(key, value);
}
getWriter().writeError("OK");
}