@Test public void testShardCommandManagerErrorWait() throws IOException, TimeoutException, ExceptionCollector { BlurObject args = new BlurObject(); args.put("table", "test"); args.put("seconds", 1); ArgumentOverlay argumentOverlay = new ArgumentOverlay(args, new BlurObjectSerDe()); TableContextFactory tableContextFactory = getTableContextFactory(); try { CommandStatus originalCommandStatusObject = new CommandStatus(null, "test", null, null, null); _manager.execute(tableContextFactory, "error", argumentOverlay, originalCommandStatusObject); fail(); } catch (ExceptionCollector e) { Throwable t = e.getCause(); assertTrue(t instanceof RuntimeException); assertEquals("error-test", t.getMessage()); } }
public Response execute(final TableContextFactory tableContextFactory, final String commandName, final ArgumentOverlay argumentOverlay, CommandStatus originalCommandStatusObject) throws IOException, TimeoutException, ExceptionCollector { final ShardServerContext shardServerContext = getShardServerContext(); AtomicBoolean running = new AtomicBoolean(true); final Command<?> command = getCommandObject(commandName, argumentOverlay); Callable<Response> callable = new Callable<Response>() { @Override public Response call() throws Exception { if (command == null) { throw new IOException("Command with name [" + commandName + "] not found."); } if (command instanceof IndexRead || command instanceof ServerRead) { return toResponse( executeReadCommand(shardServerContext, command, tableContextFactory, originalCommandStatusObject, running), command, getServerContext(tableContextFactory)); } throw new IOException("Command type of [" + command.getClass() + "] not supported."); } private CombiningContext getServerContext(final TableContextFactory tableContextFactory) { return new CombiningContext() { @Override public TableContext getTableContext(String table) throws IOException { return tableContextFactory.getTableContext(table); } @Override public BlurConfiguration getBlurConfiguration(String table) throws IOException { return getTableContext(table).getBlurConfiguration(); } }; } }; return submitDriverCallable(callable, command, originalCommandStatusObject, running); }
ShardCommandManager extends BaseCommandManager { public Response execute(final TableContextFactory tableContextFactory, final String commandName, final ArgumentOverlay argumentOverlay, CommandStatus originalCommandStatusObject) throws IOException, TimeoutException, ExceptionCollector { final ShardServerContext shardServerContext = getShardServerContext(); AtomicBoolean running = new AtomicBoolean(true); final Command<?> command = getCommandObject(commandName, argumentOverlay); Callable<Response> callable = new Callable<Response>() { @Override public Response call() throws Exception { if (command == null) { throw new IOException("Command with name [" + commandName + "] not found."); } if (command instanceof IndexRead || command instanceof ServerRead) { return toResponse( executeReadCommand(shardServerContext, command, tableContextFactory, originalCommandStatusObject, running), command, getServerContext(tableContextFactory)); } throw new IOException("Command type of [" + command.getClass() + "] not supported."); } private CombiningContext getServerContext(final TableContextFactory tableContextFactory) { return new CombiningContext() { @Override public TableContext getTableContext(String table) throws IOException { return tableContextFactory.getTableContext(table); } @Override public BlurConfiguration getBlurConfiguration(String table) throws IOException { return getTableContext(table).getBlurConfiguration(); } }; } }; return submitDriverCallable(callable, command, originalCommandStatusObject, running); } }
ShardCommandManager extends BaseCommandManager { public Response execute(final TableContextFactory tableContextFactory, final String commandName, final ArgumentOverlay argumentOverlay, CommandStatus originalCommandStatusObject) throws IOException, TimeoutException, ExceptionCollector { final ShardServerContext shardServerContext = getShardServerContext(); AtomicBoolean running = new AtomicBoolean(true); final Command<?> command = getCommandObject(commandName, argumentOverlay); Callable<Response> callable = new Callable<Response>() { @Override public Response call() throws Exception { if (command == null) { throw new IOException("Command with name [" + commandName + "] not found."); } if (command instanceof IndexRead || command instanceof ServerRead) { return toResponse( executeReadCommand(shardServerContext, command, tableContextFactory, originalCommandStatusObject, running), command, getServerContext(tableContextFactory)); } throw new IOException("Command type of [" + command.getClass() + "] not supported."); } private CombiningContext getServerContext(final TableContextFactory tableContextFactory) { return new CombiningContext() { @Override public TableContext getTableContext(String table) throws IOException { return tableContextFactory.getTableContext(table); } @Override public BlurConfiguration getBlurConfiguration(String table) throws IOException { return getTableContext(table).getBlurConfiguration(); } }; } }; return submitDriverCallable(callable, command, originalCommandStatusObject, running); } ShardCommandManager(IndexServer indexServer, File tmpPath, String commandPath, int workerThreadCount,
      int driverThreadCount, long connectionTimeout, Configuration configuration, String serverName); }
ShardCommandManager extends BaseCommandManager { public Response execute(final TableContextFactory tableContextFactory, final String commandName, final ArgumentOverlay argumentOverlay, CommandStatus originalCommandStatusObject) throws IOException, TimeoutException, ExceptionCollector { final ShardServerContext shardServerContext = getShardServerContext(); AtomicBoolean running = new AtomicBoolean(true); final Command<?> command = getCommandObject(commandName, argumentOverlay); Callable<Response> callable = new Callable<Response>() { @Override public Response call() throws Exception { if (command == null) { throw new IOException("Command with name [" + commandName + "] not found."); } if (command instanceof IndexRead || command instanceof ServerRead) { return toResponse( executeReadCommand(shardServerContext, command, tableContextFactory, originalCommandStatusObject, running), command, getServerContext(tableContextFactory)); } throw new IOException("Command type of [" + command.getClass() + "] not supported."); } private CombiningContext getServerContext(final TableContextFactory tableContextFactory) { return new CombiningContext() { @Override public TableContext getTableContext(String table) throws IOException { return tableContextFactory.getTableContext(table); } @Override public BlurConfiguration getBlurConfiguration(String table) throws IOException { return getTableContext(table).getBlurConfiguration(); } }; } }; return submitDriverCallable(callable, command, originalCommandStatusObject, running); } ShardCommandManager(IndexServer indexServer, File tmpPath, String commandPath, int workerThreadCount,
      int driverThreadCount, long connectionTimeout, Configuration configuration, String serverName); Response execute(final TableContextFactory tableContextFactory, final String commandName,
      final ArgumentOverlay argumentOverlay, CommandStatus originalCommandStatusObject); }
ShardCommandManager extends BaseCommandManager { public Response execute(final TableContextFactory tableContextFactory, final String commandName, final ArgumentOverlay argumentOverlay, CommandStatus originalCommandStatusObject) throws IOException, TimeoutException, ExceptionCollector { final ShardServerContext shardServerContext = getShardServerContext(); AtomicBoolean running = new AtomicBoolean(true); final Command<?> command = getCommandObject(commandName, argumentOverlay); Callable<Response> callable = new Callable<Response>() { @Override public Response call() throws Exception { if (command == null) { throw new IOException("Command with name [" + commandName + "] not found."); } if (command instanceof IndexRead || command instanceof ServerRead) { return toResponse( executeReadCommand(shardServerContext, command, tableContextFactory, originalCommandStatusObject, running), command, getServerContext(tableContextFactory)); } throw new IOException("Command type of [" + command.getClass() + "] not supported."); } private CombiningContext getServerContext(final TableContextFactory tableContextFactory) { return new CombiningContext() { @Override public TableContext getTableContext(String table) throws IOException { return tableContextFactory.getTableContext(table); } @Override public BlurConfiguration getBlurConfiguration(String table) throws IOException { return getTableContext(table).getBlurConfiguration(); } }; } }; return submitDriverCallable(callable, command, originalCommandStatusObject, running); } ShardCommandManager(IndexServer indexServer, File tmpPath, String commandPath, int workerThreadCount,
      int driverThreadCount, long connectionTimeout, Configuration configuration, String serverName); Response execute(final TableContextFactory tableContextFactory, final String commandName,
      final ArgumentOverlay argumentOverlay, CommandStatus originalCommandStatusObject);  }