diff --git a/src/java/org/apache/cassandra/db/BinaryMemtable.java b/src/java/org/apache/cassandra/db/BinaryMemtable.java index 9ee909c977..c6d88594dd 100644 --- a/src/java/org/apache/cassandra/db/BinaryMemtable.java +++ b/src/java/org/apache/cassandra/db/BinaryMemtable.java @@ -104,7 +104,7 @@ public class BinaryMemtable if (!isFrozen_) { isFrozen_ = true; - BinaryMemtableManager.instance().submit(cfStore.getColumnFamilyName(), this); + cfStore.submitFlush(this); cfStore.switchBinaryMemtable(key, buffer); } else diff --git a/src/java/org/apache/cassandra/db/BinaryMemtableManager.java b/src/java/org/apache/cassandra/db/BinaryMemtableManager.java deleted file mode 100644 index 3d11a431f9..0000000000 --- a/src/java/org/apache/cassandra/db/BinaryMemtableManager.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.db; - -import java.io.IOException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -import org.apache.cassandra.concurrent.DebuggableThreadPoolExecutor; -import org.apache.cassandra.concurrent.ThreadFactoryImpl; -import org.apache.cassandra.utils.LogUtil; -import org.apache.log4j.Logger; - - -/** - * Author : Avinash Lakshman ( alakshman@facebook.com) & Prashant Malik ( pmalik@facebook.com ) - */ - -public class BinaryMemtableManager -{ - private static BinaryMemtableManager instance_; - private static Lock lock_ = new ReentrantLock(); - private static Logger logger_ = Logger.getLogger(BinaryMemtableManager.class); - - static BinaryMemtableManager instance() - { - if ( instance_ == null ) - { - lock_.lock(); - try - { - if ( instance_ == null ) - instance_ = new BinaryMemtableManager(); - } - finally - { - lock_.unlock(); - } - } - return instance_; - } - - static class BinaryMemtableFlusher implements Runnable - { - private BinaryMemtable memtable_; - - BinaryMemtableFlusher(BinaryMemtable memtable) - { - memtable_ = memtable; - } - - public void run() - { - try - { - memtable_.flush(); - } - catch (IOException e) - { - if (logger_.isDebugEnabled()) - logger_.debug( LogUtil.throwableToString(e) ); - } - } - } - - private ExecutorService flusher_ = new DebuggableThreadPoolExecutor("BINARY-MEMTABLE-FLUSHER-POOL"); - - /* Submit memtables to be flushed to disk */ - void submit(String cfName, BinaryMemtable memtbl) - { - flusher_.submit( new BinaryMemtableFlusher(memtbl) ); - } -} diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java index 2196c1995b..7fdf69dec3 100644 --- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java +++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java @@ -466,7 +466,7 @@ public final class ColumnFamilyStore implements ColumnFamilyStoreMBean void forceFlushBinary() { - BinaryMemtableManager.instance().submit(getColumnFamilyName(), binaryMemtable_.get()); + submitFlush(binaryMemtable_.get()); } /** @@ -1248,6 +1248,25 @@ public final class ColumnFamilyStore implements ColumnFamilyStoreMBean }); } + static void submitFlush(final BinaryMemtable binaryMemtable) + { + logger_.info("Enqueuing flush of " + binaryMemtable); + flusher_.submit(new Runnable() + { + public void run() + { + try + { + binaryMemtable.flush(); + } + catch (IOException e) + { + throw new RuntimeException(e); + } + } + }); + } + public boolean isSuper() { return isSuper_;