Skip to content
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.

add auth backup and auth restore #76

Merged
merged 26 commits into from
Jan 5, 2021
Merged

add auth backup and auth restore #76

merged 26 commits into from
Jan 5, 2021

Conversation

xuliguov5
Copy link
Contributor

No description provided.

hugeTypes.add(HugeType.valueOf(type.toUpperCase()));
} catch (IllegalArgumentException e) {
throw new ParameterException(String.format(
"Invalid --type '%s', valid value is 'all' or " +
Copy link
Contributor

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");
Copy link
Contributor

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));
Copy link
Contributor

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));
Copy link
Contributor

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");
Copy link
Contributor

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");
Copy link
Contributor

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;
/**
Copy link
Contributor

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





Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unused code

@xuliguov5 xuliguov5 force-pushed the auth-backup-restore branch 4 times, most recently from d316753 to d8b1298 Compare December 1, 2020 11:58
@xuliguov5 xuliguov5 force-pushed the auth-backup-restore branch from d8b1298 to 038980c Compare December 1, 2020 12:06
@@ -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 !");
Copy link
Contributor

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 !");
Copy link
Contributor

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);
Copy link
Contributor

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)

}

Copy link
Contributor

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, " +
Copy link
Contributor

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 = "";



Copy link
Contributor

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();
}

Copy link
Contributor

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");
}

Copy link
Contributor

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();
Copy link
Contributor

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) {
Copy link
Contributor

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.*;
Copy link
Contributor

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.*;
Copy link
Contributor

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 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add apache license

}

}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete empty line

@xuliguov5 xuliguov5 force-pushed the auth-backup-restore branch from d962f77 to cfc5f5a Compare December 3, 2020 03:08
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;

Copy link
Contributor

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;
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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'");
Copy link
Contributor

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);
}
Copy link
Contributor

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 " +
Copy link
Contributor

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.*;
Copy link
Contributor

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 " +
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to execute command

@xuliguov5 xuliguov5 force-pushed the auth-backup-restore branch 2 times, most recently from dc371f9 to 529b88e Compare December 4, 2020 14:16
@xuliguov5 xuliguov5 force-pushed the auth-backup-restore branch from 529b88e to a984e85 Compare December 4, 2020 14:20
"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 " +
Copy link
Contributor

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 " +
Copy link
Contributor

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;
}

Copy link
Contributor

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 @@
/*
Copy link
Contributor

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.*;
Copy link
Contributor

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;
Copy link
Contributor

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) {
Copy link
Contributor

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");
Copy link
Contributor

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");
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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{
Copy link
Contributor

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"));
Copy link
Contributor

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() {
Copy link
Contributor

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);
});
Copy link
Contributor

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());
Copy link
Contributor

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(),
Copy link
Contributor

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);
Copy link
Contributor

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");
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkAllExist

@xuliguov5 xuliguov5 force-pushed the auth-backup-restore branch 5 times, most recently from 3457b13 to 8abe8a9 Compare December 9, 2020 07:45
@@ -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) ||
Copy link
Contributor

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");
Copy link
Contributor

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");
Copy link
Contributor

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,
Copy link
Contributor

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");
Copy link
Contributor

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) {
Copy link
Contributor

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()));
Copy link
Contributor

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;
Copy link
Contributor

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, () -> {
Copy link
Contributor

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() {
Copy link
Contributor

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(
Copy link
Contributor

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();
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

address it

"Strategy can't be null or empty");
E.checkArgument(AuthRestoreConflictStrategy.matchStrategy(value),
"Invalid --strategy '%s', valid value is" +
" 'stop' or 'ignore", value);
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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(),
Copy link
Contributor

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");
Copy link
Contributor

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");
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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.")
Copy link
Contributor

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 " +
Copy link
Contributor

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>
Copy link
Contributor

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);
Copy link
Contributor

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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initial capitalization?

javeme
javeme previously approved these changes Jan 4, 2021
}

public static List<String> readTestRestoreData(String filePath) {
List<String> resultList = Lists.newArrayList();
Copy link
Contributor

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",
Copy link
Contributor

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) {
Copy link
Contributor

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 " +
Copy link
Contributor

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, " +
Copy link
Contributor

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' " +
Copy link
Contributor

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();
Copy link
Contributor

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());
Copy link
Contributor

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");
Copy link
Contributor

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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accesses

javeme
javeme previously approved these changes Jan 5, 2021
@houzhizhen houzhizhen merged commit 12ec0d3 into master Jan 5, 2021
@houzhizhen houzhizhen deleted the auth-backup-restore branch January 5, 2021 08:10
@zhoney zhoney mentioned this pull request Jul 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants