@Test public void testConvertToJestActionIndex() throws Exception { HTTPBulkLoader loader = getBulkLoader(); ActionRequestKey key = ActionRequestKey.newBuilder() .setAction(Action.INDEX) .setId("myId") .build(); BulkableAction<DocumentResult> action = loader.convertToJestAction(new HTTPBulkLoader.ActionRequest(key, "fakeindex", "faketype", 100L, "{}")); assertEquals("index", action.getBulkMethodName()); assertEquals("myId", action.getId()); assertEquals("fakeindex", action.getIndex()); assertEquals("faketype", action.getType()); assertEquals("{}", action.getData(new Gson())); assertEquals(0, action.getParameter(Parameters.VERSION).size()); assertEquals(0, action.getParameter(Parameters.VERSION_TYPE).size()); ActionRequestKey keyWithVersion = ActionRequestKey.newBuilder() .setAction(Action.INDEX) .setId("myId") .setVersion(123L) .setVersionType(VersionType.EXTERNAL) .build(); BulkableAction<DocumentResult> actionWithVersion = loader.convertToJestAction(new HTTPBulkLoader.ActionRequest(keyWithVersion, "fakeindex", "faketype", 100L, "{}")); assertEquals("external", actionWithVersion.getParameter(Parameters.VERSION_TYPE).toArray()[0]); assertEquals(123L, actionWithVersion.getParameter(Parameters.VERSION).toArray()[0]); }
protected BulkableAction<DocumentResult> convertToJestAction(ActionRequest req) { BulkableAction<DocumentResult> action; switch (req.key.getAction()) { case INDEX: action = getIndexAction(req); break; case UPDATE: action = getUpdateAction(req); break; case DELETE: action = getDeleteAction(req); break; default: throw new IllegalStateException("Unknown action: " + req.key.getAction()); } return action; }
HTTPBulkLoader { protected BulkableAction<DocumentResult> convertToJestAction(ActionRequest req) { BulkableAction<DocumentResult> action; switch (req.key.getAction()) { case INDEX: action = getIndexAction(req); break; case UPDATE: action = getUpdateAction(req); break; case DELETE: action = getDeleteAction(req); break; default: throw new IllegalStateException("Unknown action: " + req.key.getAction()); } return action; } }
HTTPBulkLoader { protected BulkableAction<DocumentResult> convertToJestAction(ActionRequest req) { BulkableAction<DocumentResult> action; switch (req.key.getAction()) { case INDEX: action = getIndexAction(req); break; case UPDATE: action = getUpdateAction(req); break; case DELETE: action = getDeleteAction(req); break; default: throw new IllegalStateException("Unknown action: " + req.key.getAction()); } return action; } HTTPBulkLoader(Config config, JestClient client, Optional<Consumer<BulkReport>> onFlushOpt); }
HTTPBulkLoader { protected BulkableAction<DocumentResult> convertToJestAction(ActionRequest req) { BulkableAction<DocumentResult> action; switch (req.key.getAction()) { case INDEX: action = getIndexAction(req); break; case UPDATE: action = getUpdateAction(req); break; case DELETE: action = getDeleteAction(req); break; default: throw new IllegalStateException("Unknown action: " + req.key.getAction()); } return action; } HTTPBulkLoader(Config config, JestClient client, Optional<Consumer<BulkReport>> onFlushOpt); void addAction(String source, ActionRequest req); void flush(); void start(); void stop(); }
HTTPBulkLoader { protected BulkableAction<DocumentResult> convertToJestAction(ActionRequest req) { BulkableAction<DocumentResult> action; switch (req.key.getAction()) { case INDEX: action = getIndexAction(req); break; case UPDATE: action = getUpdateAction(req); break; case DELETE: action = getDeleteAction(req); break; default: throw new IllegalStateException("Unknown action: " + req.key.getAction()); } return action; } HTTPBulkLoader(Config config, JestClient client, Optional<Consumer<BulkReport>> onFlushOpt); void addAction(String source, ActionRequest req); void flush(); void start(); void stop();  }