@Produces(MediaType.APPLICATION_JSON)
public Response setConfigRolling(String newConfigJson) throws Exception
{
InstanceConfig wrapped = parseToConfig(newConfigJson);
Result result = null;
try
{
PseudoLock lock = context.getExhibitor().getConfigManager().newConfigBasedLock();
try
{
if ( lock.lock(context.getExhibitor().getLog(), 10, TimeUnit.SECONDS) ) // TODO consider making configurable in the future
{
if ( context.getExhibitor().getConfigManager().startRollingConfig(wrapped, null) )
{
result = new Result("OK", true);
}
}
}
finally
{
lock.unlock();
}
if ( result == null )
{
result = new Result("Another process has updated the config.", false);
}
context.getExhibitor().resetLocalConnection();
}
catch ( Exception e )
{
result = new Result(e);
}
return Response.ok(result).build();
}