Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and fix puppy for metaclient #2870

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
public class CreatePuppy extends AbstractPuppy {

private final Random _random;
private final String _parentPath = "/test";

public CreatePuppy(MetaClientInterface<String> metaclient, PuppySpec puppySpec) {
super(metaclient, puppySpec);
public CreatePuppy(MetaClientInterface<String> metaclient, PuppySpec puppySpec, String parentPath) {
super(metaclient, puppySpec, parentPath);
_random = new Random();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
public class DeletePuppy extends AbstractPuppy {

private final Random _random;
private final String _parentPath = "/test";
private final String _parentPath;

public DeletePuppy(MetaClientInterface<String> metaclient, PuppySpec puppySpec) {
super(metaclient, puppySpec);
public DeletePuppy(MetaClientInterface<String> metaclient, PuppySpec puppySpec, String parentPath) {
super(metaclient, puppySpec, parentPath);
_random = new Random();
_parentPath = parentPath;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class GetPuppy extends AbstractPuppy {
private final Random _random;
private final String _parentPath = "/test";

public GetPuppy(MetaClientInterface<String> metaclient, PuppySpec puppySpec) {
super(metaclient, puppySpec);
public GetPuppy(MetaClientInterface<String> metaclient, PuppySpec puppySpec, String parentPath) {
super(metaclient, puppySpec, parentPath);
_random = new Random();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class SetPuppy extends AbstractPuppy {
private final Random _random;
private final String _parentPath = "/test";

public SetPuppy(MetaClientInterface<String> metaclient, PuppySpec puppySpec) {
super(metaclient, puppySpec);
public SetPuppy(MetaClientInterface<String> metaclient, PuppySpec puppySpec, String parentPath) {
super(metaclient, puppySpec, parentPath);
_random = new Random();
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
public class UpdatePuppy extends AbstractPuppy {

private final Random _random;
private final String _parentPath = "/test";

public UpdatePuppy(MetaClientInterface<String> metaclient, PuppySpec puppySpec) {
super(metaclient, puppySpec);
public UpdatePuppy(MetaClientInterface<String> metaclient, PuppySpec puppySpec, String parentPath) {
super(metaclient, puppySpec, parentPath);
_random = new Random();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,12 @@ public static void simulateZkStateClosedAndReconnect(ZkMetaClient client) throws
zkClient.process(event);
}

/**
* return the name of the calling test method
*/
public static String getTestMethodName() {
StackTraceElement[] calls = Thread.currentThread().getStackTrace();
return calls[2].getMethodName();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ public abstract class AbstractPuppy implements Runnable {
protected PuppySpec _puppySpec;
public final HashMap<String, Integer> _eventChangeCounterMap;
public int _unhandledErrorCounter;
protected final String _parentPath ;

public AbstractPuppy(MetaClientInterface<String> metaclient, PuppySpec puppySpec) {
public AbstractPuppy(MetaClientInterface<String> metaclient, PuppySpec puppySpec, String parentPath) {
_metaclient = metaclient;
_puppySpec = puppySpec;
_eventChangeCounterMap = new HashMap<>();
_parentPath = parentPath;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@ public class LeaderElectionPuppy extends AbstractPuppy {
private final Random _random;
LeaderElectionClient _leaderElectionClient;

public LeaderElectionPuppy(MetaClientInterface<String> metaclient, PuppySpec puppySpec) {
super(metaclient, puppySpec);
_random = new Random();
}

public LeaderElectionPuppy(LeaderElectionClient leaderElectionClient, PuppySpec puppySpec, String leaderGroup,
String participant) {
super(leaderElectionClient.getMetaClient(), puppySpec);
super(leaderElectionClient.getMetaClient(), puppySpec, leaderGroup);
_leaderElectionClient = leaderElectionClient;
_leaderGroup = leaderGroup;
_random = new Random();
Expand Down
Loading