Search in sources :

Example 1 with TabletMutations

use of org.apache.accumulo.tserver.TabletMutations in project accumulo by apache.

the class TabletServerLogger method logManyTablets.

public void logManyTablets(Map<CommitSession, Mutations> mutations) throws IOException {
    final Map<CommitSession, Mutations> loggables = new HashMap<>(mutations);
    for (Entry<CommitSession, Mutations> entry : mutations.entrySet()) {
        if (entry.getValue().getDurability() == Durability.NONE) {
            loggables.remove(entry.getKey());
        }
    }
    if (loggables.size() == 0)
        return;
    write(loggables.keySet(), false, new Writer() {

        @Override
        public LoggerOperation write(DfsLogger logger) throws Exception {
            List<TabletMutations> copy = new ArrayList<>(loggables.size());
            for (Entry<CommitSession, Mutations> entry : loggables.entrySet()) {
                CommitSession cs = entry.getKey();
                Durability durability = entry.getValue().getDurability();
                copy.add(new TabletMutations(cs.getLogId(), cs.getWALogSeq(), entry.getValue().getMutations(), durability));
            }
            return logger.logManyTablets(copy);
        }
    });
    for (Mutations entry : loggables.values()) {
        if (entry.getMutations().size() < 1) {
            throw new IllegalArgumentException("logManyTablets: logging empty mutation list");
        }
        for (Mutation m : entry.getMutations()) {
            logSizeEstimate.addAndGet(m.numBytes());
        }
    }
}
Also used : Mutations(org.apache.accumulo.tserver.Mutations) TabletMutations(org.apache.accumulo.tserver.TabletMutations) HashMap(java.util.HashMap) CommitSession(org.apache.accumulo.tserver.tablet.CommitSession) Durability(org.apache.accumulo.core.client.Durability) LoggerOperation(org.apache.accumulo.tserver.log.DfsLogger.LoggerOperation) IOException(java.io.IOException) Entry(java.util.Map.Entry) TabletMutations(org.apache.accumulo.tserver.TabletMutations) ArrayList(java.util.ArrayList) List(java.util.List) Mutation(org.apache.accumulo.core.data.Mutation)

Example 2 with TabletMutations

use of org.apache.accumulo.tserver.TabletMutations in project accumulo by apache.

the class DfsLoggerTest method testDurabilityForGroupCommit.

@Test
public void testDurabilityForGroupCommit() {
    List<TabletMutations> lst = new ArrayList<>();
    assertEquals(Durability.NONE, DfsLogger.chooseDurabilityForGroupCommit(lst));
    TabletMutations m1 = new TabletMutations(0, 1, Collections.emptyList(), Durability.NONE);
    lst.add(m1);
    assertEquals(Durability.NONE, DfsLogger.chooseDurabilityForGroupCommit(lst));
    TabletMutations m2 = new TabletMutations(0, 1, Collections.emptyList(), Durability.LOG);
    lst.add(m2);
    assertEquals(Durability.LOG, DfsLogger.chooseDurabilityForGroupCommit(lst));
    TabletMutations m3 = new TabletMutations(0, 1, Collections.emptyList(), Durability.NONE);
    lst.add(m3);
    assertEquals(Durability.LOG, DfsLogger.chooseDurabilityForGroupCommit(lst));
    TabletMutations m4 = new TabletMutations(0, 1, Collections.emptyList(), Durability.FLUSH);
    lst.add(m4);
    assertEquals(Durability.FLUSH, DfsLogger.chooseDurabilityForGroupCommit(lst));
    TabletMutations m5 = new TabletMutations(0, 1, Collections.emptyList(), Durability.LOG);
    lst.add(m5);
    assertEquals(Durability.FLUSH, DfsLogger.chooseDurabilityForGroupCommit(lst));
    TabletMutations m6 = new TabletMutations(0, 1, Collections.emptyList(), Durability.SYNC);
    lst.add(m6);
    assertEquals(Durability.SYNC, DfsLogger.chooseDurabilityForGroupCommit(lst));
    TabletMutations m7 = new TabletMutations(0, 1, Collections.emptyList(), Durability.FLUSH);
    lst.add(m7);
    assertEquals(Durability.SYNC, DfsLogger.chooseDurabilityForGroupCommit(lst));
}
Also used : TabletMutations(org.apache.accumulo.tserver.TabletMutations) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with TabletMutations

use of org.apache.accumulo.tserver.TabletMutations in project accumulo by apache.

the class DfsLogger method logManyTablets.

public LoggerOperation logManyTablets(List<TabletMutations> mutations) throws IOException {
    Durability durability = Durability.NONE;
    List<Pair<LogFileKey, LogFileValue>> data = new ArrayList<>();
    for (TabletMutations tabletMutations : mutations) {
        LogFileKey key = new LogFileKey();
        key.event = MANY_MUTATIONS;
        key.seq = tabletMutations.getSeq();
        key.tid = tabletMutations.getTid();
        LogFileValue value = new LogFileValue();
        value.mutations = tabletMutations.getMutations();
        data.add(new Pair<>(key, value));
        if (tabletMutations.getDurability().ordinal() > durability.ordinal()) {
            durability = tabletMutations.getDurability();
        }
    }
    return logFileData(data, chooseDurabilityForGroupCommit(mutations));
}
Also used : TabletMutations(org.apache.accumulo.tserver.TabletMutations) ArrayList(java.util.ArrayList) Durability(org.apache.accumulo.core.client.Durability) LogFileValue(org.apache.accumulo.tserver.logger.LogFileValue) LogFileKey(org.apache.accumulo.tserver.logger.LogFileKey) Pair(org.apache.accumulo.core.util.Pair)

Aggregations

ArrayList (java.util.ArrayList)3 TabletMutations (org.apache.accumulo.tserver.TabletMutations)3 Durability (org.apache.accumulo.core.client.Durability)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 Mutation (org.apache.accumulo.core.data.Mutation)1 Pair (org.apache.accumulo.core.util.Pair)1 Mutations (org.apache.accumulo.tserver.Mutations)1 LoggerOperation (org.apache.accumulo.tserver.log.DfsLogger.LoggerOperation)1 LogFileKey (org.apache.accumulo.tserver.logger.LogFileKey)1 LogFileValue (org.apache.accumulo.tserver.logger.LogFileValue)1 CommitSession (org.apache.accumulo.tserver.tablet.CommitSession)1 Test (org.junit.Test)1