Skip to content

Instantly share code, notes, and snippets.

@Randgalt
Created August 1, 2014 21:07
Show Gist options
  • Save Randgalt/da89e1bde337336ff121 to your computer and use it in GitHub Desktop.
Save Randgalt/da89e1bde337336ff121 to your computer and use it in GitHub Desktop.
public static void main(String[] args) throws Exception
{
System.setProperty(DebugUtils.PROPERTY_LOG_EVENTS, "true");
TestingServer server = new TestingServer();
final int QTY = 3000;
final String PATH = "/bjn/z1/denim/mediaCapacity";
final String FILE = "4006046.";
Timing timing = new Timing();
PathChildrenCache cache = null;
CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
try
{
client.start();
cache = new PathChildrenCache(client, PATH, true);
cache.start();
for ( int i = 0; i < QTY; ++i )
{
client.create().creatingParentsIfNeeded().forPath(ZKPaths.makePath(PATH, FILE + i));
}
System.out.println("done");
for(;;)
{
if ( cache.getCurrentData().size() == QTY )
{
break;
}
Thread.sleep(1000);
}
System.out.println("done");
Random r = new Random();
for(;;)
{
Thread.sleep(r.nextInt(1000));
int i = r.nextInt(QTY);
client.setData().inBackground().forPath(ZKPaths.makePath(PATH, FILE + i), "test".getBytes());
}
}
finally
{
CloseableUtils.closeQuietly(cache);
CloseableUtils.closeQuietly(client);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment