Search in sources :

Example 1 with JournalSink

use of alluxio.master.journal.sink.JournalSink in project alluxio by Alluxio.

the class AbstractJournalSystem method removeJournalSink.

@Override
public void removeJournalSink(Master master, JournalSink journalSink) {
    try (LockResource r = new LockResource(mSinkLock.writeLock())) {
        Set<JournalSink> sinks = mJournalSinks.get(master.getName());
        if (sinks != null) {
            sinks.remove(journalSink);
            if (sinks.isEmpty()) {
                mJournalSinks.remove(master.getName());
            }
        }
        // Compute the full set of sinks on removal. Simply removing it may be incorrect, if the same
        // sink is associated with other masters.
        mAllJournalSinks.clear();
        for (Set<JournalSink> s : mJournalSinks.values()) {
            mAllJournalSinks.addAll(s);
        }
    }
}
Also used : LockResource(alluxio.resource.LockResource) JournalSink(alluxio.master.journal.sink.JournalSink)

Example 2 with JournalSink

use of alluxio.master.journal.sink.JournalSink in project alluxio by Alluxio.

the class AbstractJournalSystem method addJournalSink.

@Override
public void addJournalSink(Master master, JournalSink journalSink) {
    try (LockResource r = new LockResource(mSinkLock.writeLock())) {
        mJournalSinks.computeIfAbsent(master.getName(), (key) -> new HashSet<>()).add(journalSink);
        mAllJournalSinks.add(journalSink);
    }
}
Also used : Logger(org.slf4j.Logger) ConcurrentHashSet(alluxio.collections.ConcurrentHashSet) Master(alluxio.master.Master) LoggerFactory(org.slf4j.LoggerFactory) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) IOException(java.io.IOException) ThreadSafe(javax.annotation.concurrent.ThreadSafe) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) LockResource(alluxio.resource.LockResource) HashSet(java.util.HashSet) MetricKey(alluxio.metrics.MetricKey) Map(java.util.Map) Preconditions(com.google.common.base.Preconditions) MetricsSystem(alluxio.metrics.MetricsSystem) JournalSink(alluxio.master.journal.sink.JournalSink) Collections(java.util.Collections) Nullable(javax.annotation.Nullable) LockResource(alluxio.resource.LockResource) ConcurrentHashSet(alluxio.collections.ConcurrentHashSet) HashSet(java.util.HashSet)

Aggregations

JournalSink (alluxio.master.journal.sink.JournalSink)2 LockResource (alluxio.resource.LockResource)2 ConcurrentHashSet (alluxio.collections.ConcurrentHashSet)1 Master (alluxio.master.Master)1 MetricKey (alluxio.metrics.MetricKey)1 MetricsSystem (alluxio.metrics.MetricsSystem)1 Preconditions (com.google.common.base.Preconditions)1 IOException (java.io.IOException)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1 Nullable (javax.annotation.Nullable)1 ThreadSafe (javax.annotation.concurrent.ThreadSafe)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1