Package org.cyclop.model

Examples of org.cyclop.model.QueryHistory$QueryHistoryJaxb


    if (queries.isEmpty()) {
      LOG.debug("No data to import");
      return;
    }

    QueryHistory history = historyService.read();

    List<Future<Void>> futures = startWorkers(queries, resultWriter, status, iconfig, history);
    waitForImport(futures);

    if (iconfig.isUpdateHistory()) {
View Full Code Here


    return QueryHistory.class;
  }

  @Override
  protected QueryHistory createEmpty() {
    return new QueryHistory();
  }
View Full Code Here

    return new QueryHistory();
  }

  @Override
  public void addAndStore(@NotNull QueryEntry entry) {
    QueryHistory hist = read();
    hist.add(entry);
    store(hist);
  }
View Full Code Here

    assertFalse(storage.read(new UserIdentifier(UUID.randomUUID()), QueryHistory.class).isPresent());
  }

  @Test
  public void testEmptyHistory() {
    QueryHistory hist = new QueryHistory();
    assertEquals(0, hist.size());
    try (QueryHistory.HistoryIterator iterator = hist.iterator()) {
      assertFalse(iterator.hasNext());
    }

    CqlQuery query = new CqlQuery(CqlQueryType.SELECT, "select * from MyTable");
    QueryEntry histEntry = new QueryEntry(query, 234);
    assertFalse(hist.contains(histEntry));
    try {
      hist.iterator().next();
      fail();
    } catch (NoSuchElementException e) {
      // OK
    }
  }
View Full Code Here

  }

  @Test
  public void testCreateAndRead_SingleHistoryEntry() {
    UserIdentifier userId = new UserIdentifier(UUID.randomUUID());
    QueryHistory newHistory = new QueryHistory();

    CqlQuery query = new CqlQuery(CqlQueryType.SELECT, "select * from MyTable");
    QueryEntry histEntry = new QueryEntry(query, 6645);
    newHistory.add(histEntry);

    storage.store(userId, newHistory);

    Optional<QueryHistory> readHistory = storage.read(userId, QueryHistory.class);
    assertNotNull(readHistory);
View Full Code Here

  @Test
  public void testEvictHistory() {
    UserIdentifier userId = new UserIdentifier(UUID.randomUUID());

    {
      QueryHistory history = new QueryHistory();

      for (int i = 0; i < 600; i++) {
        CqlQuery query = new CqlQuery(CqlQueryType.SELECT, "select * from MyTable1 where id=" + i);
        history.add(new QueryEntry(query, 4563));
      }
      assertEquals(500, history.size());
      testHistRange(history, 599, 100);
      storage.store(userId, history);
    }

    {
      Optional<QueryHistory> history = storage.read(userId, QueryHistory.class);
      assertNotNull(history);
      assertEquals(500, history.get().size());
      testHistRange(history.get(), 599, 100);

      for (int i = 0; i < 10; i++) {
        CqlQuery query = new CqlQuery(CqlQueryType.SELECT, "select * from MyTable2 where id=" + i);
        history.get().add(new QueryEntry(query, 567));
      }
      storage.store(userId, history.get());
    }

    {
      QueryHistory history = storage.read(userId, QueryHistory.class).get();
      assertNotNull(history);
      assertEquals(500, history.size());

      try (QueryHistory.HistoryIterator hit = history.iterator()) {
        for (int i = 9; i >= 0; i--) {
          assertTrue(hit.hasNext());
          QueryEntry entry = hit.next();
          assertTrue(history.contains(entry));
          assertNotNull(entry.executedOnUtc);
          assertEquals("select * from MyTable2 where id=" + i, entry.query.part);
        }
        for (int i = 599; i > 110; i--) {
          assertTrue(hit.hasNext());
          QueryEntry entry = hit.next();
          assertTrue(history.contains(entry));
          assertNotNull(entry.executedOnUtc);
          assertEquals("select * from MyTable1 where id=" + i, entry.query.part);
        }
      }
    }
View Full Code Here

  @Before
  public void setup() throws Exception {
    super.setup();
    asyncFileStore.flush();
    QueryHistory history = historyService.read();
    assertNotNull(history);
    history.clear();

    assertEquals(0, history.size());

    user = historyService.getUser();
    assertNotNull(user);
    assertNotNull(user.id);
  }
View Full Code Here

    assertNotNull(user.id);
  }

  @Test
  public void testCreateReadAndClear() throws Exception {
    QueryHistory history = historyService.read();

    for (int i = 0; i < 600; i++) {
      historyService.addAndStore(new QueryEntry(new CqlQuery(CqlQueryType.SELECT, "select * " + CR
          + "from HistoryTest where " + CR + "id=" + i), 1000 + i));
      QueryHistory historyQueue = asyncFileStore.getFromWriteQueue(user).get();
      assertNotNull(historyQueue);

      // should be the same instance
      assertSame(history, historyQueue);
    }
    assertEquals(500, history.size());

    asyncFileStore.flush();
    assertFalse(asyncFileStore.getFromWriteQueue(user).isPresent());

    assertSame(history, historyService.read());

    QueryHistory readHist = storage.read(user, QueryHistory.class).get();
    assertNotSame(history, readHist);

    for (int i = 100; i < 600; i++) {
      QueryEntry tofind = new QueryEntry(new CqlQuery(CqlQueryType.SELECT, "select * from HistoryTest where id="
          + i), 2000 + i);
      assertTrue(tofind + " NOT FOUND IN: " + readHist, readHist.contains(tofind));

      ImmutableList<QueryEntry> readList = readHist.copyAsList();
      int index = readList.indexOf(tofind);
      assertTrue(index >= 0);
      QueryEntry read = readList.get(index);
      assertNotNull(read.executedOnUtc);
      assertEquals(1000 + i, read.runTime);
View Full Code Here

      tasks.add(new Callable<Void>() {

        @Override
        public Void call() throws Exception {
          for (int i = 0; i < repeatInTest; i++) {
            QueryHistory history = historyService.read();
            histories.add(history);

            QueryEntry histEntry = new QueryEntry(new CqlQuery(CqlQueryType.SELECT,
                "select * from MyTable2 where id=" + UUID.randomUUID()), 4000 + i);
            history.add(histEntry);

            verifyHistEntry(history, histEntry);

            historyService.store(history);
            if (i % 20 == 0) {
              asyncFileStore.flush();
            }

            QueryHistory readHist = historyService.read();
            verifyHistEntry(readHist, histEntry);

            executedCount.incrementAndGet();
            assertEquals(0, storage.getLockRetryCount());
          }
View Full Code Here

TOP

Related Classes of org.cyclop.model.QueryHistory$QueryHistoryJaxb

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.