コード例 #1
0
 static {
   TestUtils testUtils = new TestUtils();
   MAPPER = setupInjectablesInObjectMapper(testUtils.getTestObjectMapper());
   INDEX_MERGER = testUtils.getTestIndexMerger();
   INDEX_MERGER_V9 = testUtils.getTestIndexMergerV9();
   INDEX_IO = testUtils.getTestIndexIO();
 }
コード例 #2
0
ファイル: TaskSerdeTest.java プロジェクト: himank/druid
  public TaskSerdeTest() {
    TestUtils testUtils = new TestUtils();
    jsonMapper = testUtils.getTestObjectMapper();

    for (final Module jacksonModule : new FirehoseModule().getJacksonModules()) {
      jsonMapper.registerModule(jacksonModule);
    }
  }
コード例 #3
0
  @Test
  public void testRestartCleansOldStatus() throws Exception {
    cf.create()
        .creatingParentsIfNeeded()
        .forPath(joiner.join(tasksPath, task.getId()), jsonMapper.writeValueAsBytes(task));

    Assert.assertTrue(
        TestUtils.conditionValid(
            new IndexingServiceCondition() {
              @Override
              public boolean isValid() {
                try {
                  return cf.checkExists().forPath(joiner.join(statusPath, task.getId())) != null;
                } catch (Exception e) {
                  return false;
                }
              }
            }));
    // simulate node restart
    workerTaskMonitor.stop();
    workerTaskMonitor = createTaskMonitor();
    workerTaskMonitor.start();
    List<TaskAnnouncement> announcements = workerCuratorCoordinator.getAnnouncements();
    Assert.assertEquals(1, announcements.size());
    Assert.assertEquals(task.getId(), announcements.get(0).getTaskStatus().getId());
    Assert.assertEquals(
        TaskStatus.Status.FAILED, announcements.get(0).getTaskStatus().getStatusCode());
  }
コード例 #4
0
  @Test
  public void testRunTask() throws Exception {
    cf.create()
        .creatingParentsIfNeeded()
        .forPath(joiner.join(tasksPath, task.getId()), jsonMapper.writeValueAsBytes(task));

    Assert.assertTrue(
        TestUtils.conditionValid(
            new IndexingServiceCondition() {
              @Override
              public boolean isValid() {
                try {
                  return cf.checkExists().forPath(joiner.join(tasksPath, task.getId())) == null;
                } catch (Exception e) {
                  return false;
                }
              }
            }));

    Assert.assertTrue(
        TestUtils.conditionValid(
            new IndexingServiceCondition() {
              @Override
              public boolean isValid() {
                try {
                  return cf.checkExists().forPath(joiner.join(statusPath, task.getId())) != null;
                } catch (Exception e) {
                  return false;
                }
              }
            }));

    TaskAnnouncement taskAnnouncement =
        jsonMapper.readValue(
            cf.getData().forPath(joiner.join(statusPath, task.getId())), TaskAnnouncement.class);

    Assert.assertEquals(task.getId(), taskAnnouncement.getTaskStatus().getId());
    Assert.assertEquals(
        TaskStatus.Status.RUNNING, taskAnnouncement.getTaskStatus().getStatusCode());
  }
コード例 #5
0
  @Test
  public void testStatusAnnouncementsArePersistent() throws Exception {
    cf.create()
        .creatingParentsIfNeeded()
        .forPath(joiner.join(tasksPath, task.getId()), jsonMapper.writeValueAsBytes(task));

    Assert.assertTrue(
        TestUtils.conditionValid(
            new IndexingServiceCondition() {
              @Override
              public boolean isValid() {
                try {
                  return cf.checkExists().forPath(joiner.join(statusPath, task.getId())) != null;
                } catch (Exception e) {
                  return false;
                }
              }
            }));
    // ephermal owner is 0 is created node is PERSISTENT
    Assert.assertEquals(
        0, cf.checkExists().forPath(joiner.join(statusPath, task.getId())).getEphemeralOwner());
  }
コード例 #6
0
  @Before
  public void setUp() throws Exception {
    emitter = EasyMock.createMock(ServiceEmitter.class);
    EmittingLogger.registerEmitter(emitter);
    queryRunnerFactoryConglomerate =
        EasyMock.createStrictMock(QueryRunnerFactoryConglomerate.class);
    monitorScheduler = EasyMock.createStrictMock(MonitorScheduler.class);
    publishCountDown = new CountDownLatch(1);
    announcedSinks = 0;
    pushedSegments = 0;
    tmpDir = temporaryFolder.newFolder();
    TestUtils testUtils = new TestUtils();
    mapper = testUtils.getTestObjectMapper();

    tqc =
        mapper.readValue(
            "{\"startDelay\":\"PT0S\", \"restartDelay\":\"PT1S\", \"storageSyncRate\":\"PT0.5S\"}",
            TaskQueueConfig.class);
    indexSpec = new IndexSpec();

    if (taskStorageType.equals("HeapMemoryTaskStorage")) {
      ts = new HeapMemoryTaskStorage(new TaskStorageConfig(null) {});
    } else if (taskStorageType.equals("MetadataTaskStorage")) {
      testDerbyConnector = derbyConnectorRule.getConnector();
      mapper.registerSubtypes(
          new NamedType(MockExceptionalFirehoseFactory.class, "mockExcepFirehoseFactory"),
          new NamedType(MockFirehoseFactory.class, "mockFirehoseFactory"));
      testDerbyConnector.createTaskTables();
      testDerbyConnector.createSegmentTable();
      ts =
          new MetadataTaskStorage(
              testDerbyConnector,
              new TaskStorageConfig(null),
              new SQLMetadataStorageActionHandlerFactory(
                  testDerbyConnector,
                  derbyConnectorRule.metadataTablesConfigSupplier().get(),
                  mapper));
    } else {
      throw new RuntimeException(String.format("Unknown task storage type [%s]", taskStorageType));
    }

    serverView =
        new FilteredServerView() {
          @Override
          public void registerSegmentCallback(
              Executor exec, ServerView.SegmentCallback callback, Predicate<DataSegment> filter) {
            segmentCallbacks.add(callback);
          }
        };
    setUpAndStartTaskQueue(
        new DataSegmentPusher() {
          @Override
          public String getPathForHadoop(String dataSource) {
            throw new UnsupportedOperationException();
          }

          @Override
          public DataSegment push(File file, DataSegment segment) throws IOException {
            pushedSegments++;
            return segment;
          }
        });
  }
コード例 #7
0
 static {
   TestUtils testUtils = new TestUtils();
   MAPPER = testUtils.getTestObjectMapper();
   INDEX_MERGER = testUtils.getTestIndexMerger();
   INDEX_IO = testUtils.getTestIndexIO();
 }