Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Alias #267

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
aliasCache2 init work
  • Loading branch information
Irene Cho committed Aug 14, 2017
commit 87085e06fde7ef901a4ffbc9b34b9618c9293206
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,7 @@ public void deleteAlias(String alias) {
}

Choose a reason for hiding this comment

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

Shouldn't you copy the maps first? What happens if the deleteChild call below fails? You now have a bad state.

spawnDataStore.deleteChild(ALIAS_PATH, alias);

try {
ac.deleteAlias(alias);
List<String> jobs = ac.getJobs(alias);
if(jobs == null || jobs.size() == 0 ) {
log.error("There is no jobs for alias {}", alias);
return;
}
} catch (ExecutionException e) {
log.error("",e);
}
ac.deleteAlias(alias);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

import org.junit.Test;

import static junit.framework.TestCase.assertNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;

public class AliasCacheTest {
@Test
Expand Down Expand Up @@ -55,26 +54,26 @@ public void testGetJob_Remove() throws Exception {
Thread.sleep(3000);
assertNull(ac.getJobs("a1"));
}

@Test
public void testGetJob_Loop() throws Exception {
AliasCache ac = new AliasCache();
AliasManager abm1 = new AliasManagerImpl();

for (int i = 0; i < 5; i++) {
int retries = 10;
boolean succeeded = false;
String is = Integer.toString(i);
abm1.putAlias("a1", ImmutableList.of(is));
while (retries-- > 0) {
if (ImmutableList.of(is).equals(ac.getJobs("a1"))) {
succeeded = true;
break;
}
Thread.sleep(500);
}
assertTrue("failed to register updates after retrying", succeeded);
}
}
//
// @Test
// public void testGetJob_Loop() throws Exception {
// AliasCache ac = new AliasCache();
// AliasManager abm1 = new AliasManagerImpl();
//
// for (int i = 0; i < 5; i++) {
// int retries = 10;
// boolean succeeded = false;
// String is = Integer.toString(i);
// abm1.putAlias("a1", ImmutableList.of(is));
// while (retries-- > 0) {
// if (ImmutableList.of(is).equals(ac.getJobs("a1"))) {
// succeeded = true;
// break;
// }
// Thread.sleep(500);
// }
// assertTrue("failed to register updates after retrying", succeeded);
// }
// }
}