-
Notifications
You must be signed in to change notification settings - Fork 28
Conversation
hugeTypes.add(HugeType.valueOf(type.toUpperCase())); | ||
} catch (IllegalArgumentException e) { | ||
throw new ParameterException(String.format( | ||
"Invalid --type '%s', valid value is 'all' or " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align with ParameterException
@Override | ||
public String convert(String value) { | ||
E.checkArgument(value != null && !value.isEmpty(), | ||
"Strategy can't be null or empty"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align
return value; | ||
} else { | ||
throw new ParameterException(String.format( | ||
"Invalid --strategy '%s', valid value is 'stop' or 'ignore", value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align with ParameterException, and ensure don't exceed 80 chars
break; | ||
default: | ||
throw new AssertionError(String.format( | ||
"Bad backup type: %s", type)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align with AssertionError
protected void backupUsers() { | ||
Printer.print("Users backup started"); | ||
List<User> users = retry(this.client.authManager()::listUsers, | ||
"querying users of authority"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align with this
protected void backupGroups() { | ||
Printer.print("Groups backup started"); | ||
List<Group> groups = retry(this.client.authManager()::listGroups, | ||
"querying groups of authority"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also check other places for alignment
private int conflict_status = 0; | ||
private AuthRestoreStrategy strategy; | ||
private String initPassword; | ||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use "/*" here, "/**" is just for java doc
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty lines
|
||
} | ||
|
||
public static void main(String[] strings) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unused code
d316753
to
d8b1298
Compare
d8b1298
to
038980c
Compare
@@ -328,6 +337,22 @@ private void execute(String subCmd, JCommander jCommander) { | |||
Printer.print("Tasks are cleared[force=%s]", | |||
taskClear.force()); | |||
break; | |||
case "auth-backup": | |||
Printer.print("Auth backup start !"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Auth backup start..."
authBackupManager.authBackup(authBackup.types()); | ||
break; | ||
case "auth-restore": | ||
Printer.print("Auth restore start !"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Printer.print("Exception in 'main' is %s", e); | ||
System.exit(-1); | ||
} | ||
System.exit(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw exception if test mode else System.exit(-1)
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line
|
||
@Parameter(names = {"--strategy"}, | ||
converter = AuthStrategyConverter.class, | ||
description = "restore strategy, " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve description
public static final String TRUST_STORE_PASSWORD = ""; | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unused line
.configSSL(trustStoreFile, trustStorePassword) | ||
.build(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
}catch (Exception e) { | ||
Printer.print("Failed to close file"); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
}finally { | ||
if(is != null) { | ||
try { | ||
is.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use try (resource)
to auto close
if(is != null) { | ||
try { | ||
is.close(); | ||
}catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add space tp "}catch"
import com.beust.jcommander.ParameterException; | ||
import com.beust.jcommander.Parameters; | ||
import com.beust.jcommander.ParametersDelegate; | ||
import com.beust.jcommander.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use * in import
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put java.* and org.* first and put com.baidu.hugegraph last
@@ -0,0 +1,30 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add apache license
} | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete empty line
d962f77
to
cfc5f5a
Compare
import com.baidu.hugegraph.driver.GraphManager; | ||
import com.baidu.hugegraph.driver.GremlinManager; | ||
import com.baidu.hugegraph.driver.HugeClient; | ||
import com.baidu.hugegraph.driver.SchemaManager; | ||
import com.baidu.hugegraph.driver.TaskManager; | ||
import com.baidu.hugegraph.driver.TraverserManager; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete empty line
import com.baidu.hugegraph.util.E; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.nio.file.Paths; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format imports
@@ -404,27 +430,95 @@ private GraphMode mode() { | |||
|
|||
public static void main(String[] args) { | |||
HugeGraphCommand cmd = new HugeGraphCommand(); | |||
|
|||
JCommander jCommander = parseJCommand(args, cmd); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to parseCommand and catch it
Printer.print("Must provide one sub-command"); | ||
jCommander.usage(); | ||
System.exit(-1); | ||
printCommonCommand(jCommander); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printCommandsCategory
} | ||
Printer.print("======================================"); | ||
Printer.print("You can use 'help' to see more detailed " + | ||
"\ncommands, such as './bin/hugegraph help'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help
help sub-command
} else { | ||
System.out.println(" Unrecognized command : " | ||
+ info); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only print if type y else not, default is [n]
} | ||
|
||
public static boolean isPrintStackException() { | ||
System.out.println("Input yes or no to view the stack " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type y(yes) to print exception stack[default n]?
import com.baidu.hugegraph.manager.GremlinManager; | ||
import com.baidu.hugegraph.manager.RestoreManager; | ||
import com.baidu.hugegraph.manager.TasksManager; | ||
import com.baidu.hugegraph.manager.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't import *
} | ||
try { | ||
jCommander.parse(args); | ||
} catch (ParameterException e) { | ||
Printer.print(e.getMessage()); | ||
System.exit(-1); | ||
throw new ParameterException(String.format( | ||
"make sure your command, you can use " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected command
System.exit(-1); | ||
} else { | ||
throw new RuntimeException( | ||
"Exception in 'main' is", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failed to execute command
dc371f9
to
529b88e
Compare
529b88e
to
a984e85
Compare
"edge_label,property_key,index_label'") | ||
description = "Type of schema/data. Concat with ',' if more " + | ||
"than one. other types include ‘all’ and ‘schema’" + | ||
" .’all' means all vertices, edges and schema,in " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a blank after ","
@Parameter(names = {"--strategy"}, | ||
converter = AuthStrategyConverter.class, | ||
description = "The strategy that needs to be chosen in the " + | ||
"event of a conflict in restore. strategy include " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid Strategies
public void initPassword(String initPassword) { | ||
this.initPassword = initPassword; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete empty line
@@ -0,0 +1,150 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add apache license
import com.baidu.hugegraph.base.Printer; | ||
import com.baidu.hugegraph.base.RetryManager; | ||
import com.baidu.hugegraph.base.ToolClient; | ||
import com.baidu.hugegraph.base.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't import *
while ((line = reader.readLine()) != null) { | ||
consumer.accept(type.string(), line); | ||
} | ||
String line; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think keep origin is ok
|
||
public final class ToolUtil { | ||
|
||
public static void shutdown(List<ToolManager> taskManager) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taskManagers
boolean isTestNode) { | ||
if (isTestNode) { | ||
throw new ParameterException( | ||
"Failed to parse command"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new ParameterException("Failed to parse command");
boolean isTestNode) { | ||
if (isTestNode) { | ||
throw new ParameterException( | ||
"Failed to parse command"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
com.baidu.hugegraph.traversal.algorithm.SubGraphTraverser, | ||
com.baidu.hugegraph.traversal.optimize.Text, | ||
com.baidu.hugegraph.traversal.optimize.TraversalUtil, | ||
com.baidu.hugegraph.util.DateUtil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update after https://github.com/hugegraph/hugegraph/pull/1289 merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merged, rebase
import com.baidu.hugegraph.testutil.Assert; | ||
import com.google.common.collect.Maps; | ||
|
||
public class AuthRestoreTest extends AuthTest{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add blank before "{"
for (Target target : targets) { | ||
targetMap.put(target.name(), target); | ||
} | ||
Assert.assertTrue(targetMap.containsKey("test_target1")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
belong and access?
} | ||
|
||
@Test | ||
public void testAuthRestoreByStrategyConfict() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conflict
|
||
Assert.assertThrows(RuntimeException.class, () -> { | ||
HugeGraphCommand.main(args); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also assert exception message
int conflict = this.conflict_status; | ||
User restoreUser = JsonUtil.fromJson(userStr, User.class); | ||
if (userMap.containsKey(restoreUser.name())) { | ||
User resourceUser = userMap.get(restoreUser.name()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
existUser
} | ||
for (String str : belongJsons) { | ||
Belong restoreBelong = JsonUtil.fromJson(str, Belong.class); | ||
if (checkIdMaps(restoreBelong.user().toString(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve checkIdMaps
}, "Restore access of authority"); | ||
counts++; | ||
} | ||
Printer.print("Restore accesses finished, counts is %s !", counts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
count
restoreBelong.group(this.idsMap.get(restoreBelong.group().toString())); | ||
retry(() -> { | ||
return this.client.authManager().createBelong(restoreBelong); | ||
}, "Restore targets of authority"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
belongs
this.usersByName.put(restoreUser.name(), restoreUser); | ||
} | ||
|
||
private boolean checkIdMaps(String oneId, String otherId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkAllExist
3457b13
to
8abe8a9
Compare
4ab761e
to
b84753b
Compare
@@ -1043,8 +1043,8 @@ public GraphMode convert(String value) { | |||
public String convert(String value) { | |||
E.checkArgument(value != null && !value.isEmpty(), | |||
"Strategy can't be null or empty"); | |||
E.checkArgument(AuthRestoreStrategy.STOP.string().equals(value) || | |||
AuthRestoreStrategy.IGNORE.string().equals(value), | |||
E.checkArgument(AuthRestoreConflictStrategy.STOP.string().equals(value) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exceed 80 chars, we can add AuthRestoreConflictStrategy.STOP.match(value) method
return client.authManager().createUser(restoreUser); | ||
}, "Restore users of authority"); | ||
return client.authManager().createUser(restoreUser); | ||
}, "Restore users of authority"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align with User
return client.authManager().createGroup(restoreGroup); | ||
}, "Restore groups of authority"); | ||
return client.authManager().createGroup(restoreGroup); | ||
}, "Restore groups of authority"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -420,12 +424,16 @@ public void checkConflict() { | |||
conflict++; | |||
} | |||
if (conflict > NO_CONFLICT) { | |||
E.checkArgument(strategy != AuthRestoreStrategy.STOP, | |||
E.checkArgument(strategy != AuthRestoreConflictStrategy.STOP, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't check it since will return conflicts if strategy=STOP
return client.authManager().createTarget(restoreTarget); | ||
}, "Restore targets of authority"); | ||
return client.authManager().createTarget(restoreTarget); | ||
}, "Restore targets of authority"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -53,7 +53,7 @@ public static boolean checkFileExists(String filePath) { | |||
return false; | |||
} | |||
|
|||
public static List<String> getFileDirectoryNames(String filePath) { | |||
public static List<String> getFileSubdirectories(String filePath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just subdirectories() method is ok
"Restore targets strategy is not found"); | ||
if (strategy == AuthRestoreConflictStrategy.STOP) { | ||
conflicts.add(String.format("target name : %s", | ||
restoreTarget.name())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use conflicts.add(restoreTarget) and rewrite restoreTarget.toString
@@ -69,7 +70,7 @@ | |||
private Map<String, Target> targetsByName; | |||
private Map<String, Belong> belongsByName; | |||
private Map<String, Access> accessesByName; | |||
private List<AuthManager> authManagers; | |||
private List<String> conflicts; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just let checkConflict() return List<String> conflicts
"--init-password", "123456" | ||
}; | ||
|
||
Assert.assertThrows(IllegalArgumentException.class, () -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't throw IllegalArgumentException, prefer IllegalStateException
} | ||
|
||
@Test | ||
public void testAuthRestoreWithStopStrategy() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testAuthRestoreWithConflictAndStopStrategy
try { | ||
hugeTypes.add(HugeType.valueOf(type.toUpperCase())); | ||
} catch (IllegalArgumentException e) { | ||
throw new ParameterException(String.format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace ParameterException with IllegalArgumentException
|
||
private void doRestore() { | ||
for (AuthManager authManager : this.authManagers) { | ||
authManager.checkConflict(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
address it
this.hdfsConf = hdfsConf; | ||
} | ||
|
||
public void retry(int retry) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to line 849
public static final String strategy = "stop"; | ||
|
||
@Override | ||
public String convert(String value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
address it
this.hdfsConf = hdfsConf; | ||
} | ||
|
||
public void retry(int retry) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to line 849, put similar methods together
public static final String strategy = "stop"; | ||
|
||
@Override | ||
public String convert(String value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
address it
98ed387
to
65f03fa
Compare
"Strategy can't be null or empty"); | ||
E.checkArgument(AuthRestoreConflictStrategy.matchStrategy(value), | ||
"Invalid --strategy '%s', valid value is" + | ||
" 'stop' or 'ignore", value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put space to the previous line
User restoreUser = entry.getValue(); | ||
restoreUser.password(initPassword); | ||
User user = retry(() -> { | ||
return client.authManager().createUser(restoreUser); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add 4 spaces
for (Map.Entry<String, Target> entry : targetsByName.entrySet()) { | ||
Target restoreTarget = entry.getValue(); | ||
Target target = retry(() -> { | ||
return client.authManager().createTarget(restoreTarget); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
"Querying belongs of authority"); | ||
Map<String, Belong> belongMap = Maps.newHashMap(); | ||
for (Belong belong : belongs) { | ||
belongMap.put(belong.user() + ":" + belong.group(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add local var key = belong.user() + ":" + belong.group()
restoreBelong.group(idsMap.get(restoreBelong.group().toString())); | ||
retry(() -> { | ||
return client.authManager().createBelong(restoreBelong); | ||
}, "Restore belongs of authority"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align with retry
restoreAccess.group(idsMap.get(restoreAccess.group().toString())); | ||
retry(() -> { | ||
return client.authManager().createAccess(restoreAccess); | ||
}, "Restore access of authority"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
return false; | ||
} | ||
|
||
public static boolean matchStrategy(AuthRestoreConflictStrategy strategy) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems unused method
return false; | ||
} | ||
|
||
public static boolean matchStopStrategy(AuthRestoreConflictStrategy strategy) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't set static and change to isStopStrategy(), move to line 53
also add isIgnoreStrategy()
|
||
@Parameter(names = {"--init-password"}, arity = 1, | ||
description = "Init user password, if restore type include " + | ||
"'user', must init user password.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please specify the init-password of users
@Parameter(names = {"--strategy"}, | ||
converter = AuthStrategyConverter.class, | ||
description = "The strategy needs to be chosen in the event " + | ||
"of a conflict in restore. valid strategies include " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in restore => when restoring
checkstyle.xml
Outdated
<!--覆盖clone()方法时调用了super.clone()方法--> | ||
<module name="SuperClone"/> | ||
</module> | ||
</module> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add empty line
idsMap.put(restoreGroup.id().toString(), group.id().toString()); | ||
count++; | ||
} | ||
Printer.print("Restore groups finished, count is %d !", count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"..., total count is %d"
public void backup() { | ||
Printer.print("Belongs backup started..."); | ||
List<Belong> belongs = retry(client.authManager()::listBelongs, | ||
"querying belongs of authority"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initial capitalization?
} | ||
|
||
public static List<String> readTestRestoreData(String filePath) { | ||
List<String> resultList = Lists.newArrayList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resultList => results
baos.write(builder.toString().getBytes(API.CHARSET)); | ||
os.write(baos.toByteArray()); | ||
} catch (IOException e) { | ||
throw new ToolsException("Failed writeText file path is %s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failed write file path is
return list; | ||
} | ||
|
||
public static void clearFile(String filePath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems function is clear directories
@Parameter(names = {"--strategy"}, | ||
converter = AuthStrategyConverter.class, | ||
description = "The strategy needs to be chosen in the event " + | ||
"of a conflict when restoring. valid " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid
listConverter = AuthHugeTypeConverter.class, | ||
description = "Type of auth data to restore and backup, concat with " + | ||
"',' if more than one. 'all' means all auth information" + | ||
" in other words, 'all' equals with 'user, group, target, " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
. In other words
"',' if more than one. 'all' means all auth information" + | ||
" in other words, 'all' equals with 'user, group, target, " + | ||
"belong, access'. in addition, only 'belong' or 'access' " + | ||
"can not backup or restore, if type contains 'belong' " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'belong' or 'access' can not backup or restore alone
public static class AuthBackup extends AuthBackupRestore { | ||
|
||
@ParametersDelegate | ||
private AuthTypes types = new AuthTypes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move types to AuthBackupRestore
} | ||
} catch (IOException e) { | ||
throw new ToolsException("Failed to deserialize %s from %s", | ||
e, resultList, type.string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type.string(), resultList
@Override | ||
public List<String> checkConflict() { | ||
List<Group> groups = retry(client.authManager()::listGroups, | ||
"querying users of authority"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
groups
restoreAccess.group(idsMap.get(restoreAccess.group().toString())); | ||
retry(() -> { | ||
return client.authManager().createAccess(restoreAccess); | ||
}, "restore access of authority"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accesses
No description provided.