coredump checkpoint
diff --git a/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/lifecycle/ApplicationThreadExecutor.java b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/lifecycle/ApplicationThreadExecutor.java
new file mode 100644
index 0000000..948584e
--- /dev/null
+++ b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/lifecycle/ApplicationThreadExecutor.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ *
+ * 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 edu.uci.ics.hyracks.api.lifecycle;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+
+public class ApplicationThreadExecutor implements Executor {
+
+ private final ThreadFactory threadFactory;
+ private final Executor executor = Executors.newCachedThreadPool();
+
+ public ApplicationThreadExecutor(ThreadFactory threadFactory) {
+ this.threadFactory = threadFactory;
+ }
+
+ @Override
+ public void execute(Runnable command) {
+ Thread t = threadFactory.newThread(command);
+ t.setUncaughtExceptionHandler(LifeCycleComponentManager.INSTANCE);
+ executor.execute(t);
+ }
+
+}
diff --git a/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/lifecycle/ILifeCycleComponent.java b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/lifecycle/ILifeCycleComponent.java
new file mode 100644
index 0000000..fb96456
--- /dev/null
+++ b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/lifecycle/ILifeCycleComponent.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ *
+ * 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 edu.uci.ics.hyracks.api.lifecycle;
+
+import java.io.OutputStream;
+
+public interface ILifeCycleComponent {
+
+ public void start();
+
+ public void stop(boolean dumpState, OutputStream ouputStream);
+}
diff --git a/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/lifecycle/ILifeCycleComponentManager.java b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/lifecycle/ILifeCycleComponentManager.java
new file mode 100644
index 0000000..6247c17
--- /dev/null
+++ b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/lifecycle/ILifeCycleComponentManager.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ *
+ * 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 edu.uci.ics.hyracks.api.lifecycle;
+
+import java.io.IOException;
+import java.lang.Thread.UncaughtExceptionHandler;
+import java.util.Map;
+
+public interface ILifeCycleComponentManager extends UncaughtExceptionHandler {
+
+ public void register(ILifeCycleComponent component);
+
+ public void startAll();
+
+ public void stopAll(boolean dumpState) throws IOException;
+
+ public void configure(Map<String, String> configuration);
+}
diff --git a/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/lifecycle/LifeCycleComponentManager.java b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/lifecycle/LifeCycleComponentManager.java
new file mode 100644
index 0000000..314ac67
--- /dev/null
+++ b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/lifecycle/LifeCycleComponentManager.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ *
+ * 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 edu.uci.ics.hyracks.api.lifecycle;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class LifeCycleComponentManager implements ILifeCycleComponentManager {
+
+ public static LifeCycleComponentManager INSTANCE = new LifeCycleComponentManager();
+
+ public static final class Config {
+ public static final String KEY_DUMP_PATH = "DUMP_PATH";
+ }
+
+ private static final Logger LOGGER = Logger.getLogger(LifeCycleComponentManager.class.getName());
+
+ private final List<ILifeCycleComponent> components = new ArrayList<ILifeCycleComponent>();
+ private boolean stopInitiated = false;
+ private String dumpPath;
+ private boolean configured = false;
+
+ private LifeCycleComponentManager() {
+ }
+
+ @Override
+ public void uncaughtException(Thread t, Throwable e) {
+ if (LOGGER.isLoggable(Level.SEVERE)) {
+ LOGGER.severe("Uncaught Exception from thread" + t.getName() + " message:" + e.getMessage());
+ e.printStackTrace();
+ }
+ try {
+ stopAll(true);
+ } catch (IOException e1) {
+ if (LOGGER.isLoggable(Level.SEVERE)) {
+ LOGGER.severe("Exception in stopping Asterix. " + e1.getMessage());
+ }
+ }
+ }
+
+ @Override
+ public synchronized void register(ILifeCycleComponent component) {
+ components.add(component);
+ }
+
+ @Override
+ public void startAll() {
+ for (ILifeCycleComponent component : components) {
+ component.start();
+ }
+ }
+
+ @Override
+ public synchronized void stopAll(boolean dumpState) throws IOException {
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.severe("Attempting to stop " + this);
+ }
+ if (stopInitiated) {
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.severe("Stop already in progress");
+ }
+ return;
+ }
+ if (!configured) {
+ if (LOGGER.isLoggable(Level.SEVERE)) {
+ LOGGER.severe("Lifecycle management not configured" + this);
+ }
+ return;
+ }
+
+ stopInitiated = true;
+ if (LOGGER.isLoggable(Level.SEVERE)) {
+ LOGGER.severe("Stopping Asterix instance");
+ }
+
+ FileOutputStream componentDumpStream = null;
+ String componentDumpPath = null;
+ for (int index = components.size() - 1; index >= 0; index--) {
+ ILifeCycleComponent component = components.get(index);
+ try {
+ if (dumpState) {
+ componentDumpPath = dumpPath + File.separator + component.getClass().getName() + "-coredump";
+ componentDumpStream = new FileOutputStream(componentDumpPath);
+
+ }
+ if (LOGGER.isLoggable(Level.SEVERE)) {
+ LOGGER.severe("Stopping component instance" + component.getClass().getName() + " dump state "
+ + dumpState + " dump path " + componentDumpPath);
+ }
+ component.stop(dumpState, componentDumpStream);
+ } catch (Exception e) {
+ if (LOGGER.isLoggable(Level.SEVERE)) {
+ LOGGER.severe("Exception in stopping component " + component.getClass().getName());
+ }
+ } finally {
+ if (componentDumpStream != null) {
+ componentDumpStream.close();
+ }
+ }
+ }
+ stopInitiated = false;
+
+ }
+
+ @Override
+ public void configure(Map<String, String> configuration) {
+ dumpPath = configuration.get(Config.KEY_DUMP_PATH);
+ if (dumpPath == null) {
+ dumpPath = System.getProperty("user.dir");
+ if (LOGGER.isLoggable(Level.SEVERE)) {
+ LOGGER.severe("dump path not configured. Using current directory " + dumpPath);
+ }
+ }
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.severe("LifecycleComponentManager configurd " + this);
+ }
+ configured = true;
+ }
+
+}
diff --git a/hyracks/hyracks-control/hyracks-control-nc/src/main/java/edu/uci/ics/hyracks/control/nc/NCDriver.java b/hyracks/hyracks-control/hyracks-control-nc/src/main/java/edu/uci/ics/hyracks/control/nc/NCDriver.java
index d31d09e..81b91e8 100644
--- a/hyracks/hyracks-control/hyracks-control-nc/src/main/java/edu/uci/ics/hyracks/control/nc/NCDriver.java
+++ b/hyracks/hyracks-control/hyracks-control-nc/src/main/java/edu/uci/ics/hyracks/control/nc/NCDriver.java
@@ -16,6 +16,7 @@
import org.kohsuke.args4j.CmdLineParser;
+import edu.uci.ics.hyracks.api.lifecycle.LifeCycleComponentManager;
import edu.uci.ics.hyracks.control.common.controllers.NCConfig;
public class NCDriver {
@@ -31,6 +32,8 @@
}
final NodeControllerService nService = new NodeControllerService(ncConfig);
+ System.out.println("Setting uncaught exception handler " + LifeCycleComponentManager.INSTANCE);
+ Thread.currentThread().setUncaughtExceptionHandler(LifeCycleComponentManager.INSTANCE);
nService.start();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
diff --git a/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/IIndexLifecycleManager.java b/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/IIndexLifecycleManager.java
index c4f43b9..9badc58 100644
--- a/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/IIndexLifecycleManager.java
+++ b/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/IIndexLifecycleManager.java
@@ -3,8 +3,9 @@
import java.util.List;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.api.lifecycle.ILifeCycleComponent;
-public interface IIndexLifecycleManager {
+public interface IIndexLifecycleManager extends ILifeCycleComponent {
public IIndex getIndex(long resourceID);
public void register(long resourceID, IIndex index) throws HyracksDataException;
diff --git a/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IndexLifecycleManager.java b/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IndexLifecycleManager.java
index 197aecc..63557f7 100644
--- a/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IndexLifecycleManager.java
+++ b/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IndexLifecycleManager.java
@@ -1,5 +1,6 @@
package edu.uci.ics.hyracks.storage.am.common.dataflow;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -7,175 +8,199 @@
import java.util.Map;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.api.lifecycle.LifeCycleComponentManager;
import edu.uci.ics.hyracks.storage.am.common.api.IIndex;
import edu.uci.ics.hyracks.storage.am.common.api.IIndexLifecycleManager;
public class IndexLifecycleManager implements IIndexLifecycleManager {
- private static final long DEFAULT_MEMORY_BUDGET = 1024 * 1024 * 100; // 100 megabytes
+ private static final long DEFAULT_MEMORY_BUDGET = 1024 * 1024 * 100; // 100
+ // megabytes
- private final Map<Long, IndexInfo> indexInfos;
- private final long memoryBudget;
+ private final Map<Long, IndexInfo> indexInfos;
+ private final long memoryBudget;
- private long memoryUsed;
+ private long memoryUsed;
- public IndexLifecycleManager() {
- this(DEFAULT_MEMORY_BUDGET);
- }
+ public IndexLifecycleManager() {
+ this(DEFAULT_MEMORY_BUDGET);
+ }
- public IndexLifecycleManager(long memoryBudget) {
- this.indexInfos = new HashMap<Long, IndexInfo>();
- this.memoryBudget = memoryBudget;
- this.memoryUsed = 0;
- }
+ public IndexLifecycleManager(long memoryBudget) {
+ this.indexInfos = new HashMap<Long, IndexInfo>();
+ this.memoryBudget = memoryBudget;
+ this.memoryUsed = 0;
+ LifeCycleComponentManager.INSTANCE.register(this);
+ }
- private boolean evictCandidateIndex() throws HyracksDataException {
- // Why min()? As a heuristic for eviction, we will take an open index (an index consuming memory)
- // that is not being used (refcount == 0) and has been least recently used. The sort order defined
- // for IndexInfo maintains this. See IndexInfo.compareTo().
- IndexInfo info = Collections.min(indexInfos.values());
- if (info.referenceCount != 0 || !info.isOpen) {
- return false;
- }
+ private boolean evictCandidateIndex() throws HyracksDataException {
+ // Why min()? As a heuristic for eviction, we will take an open index
+ // (an index consuming memory)
+ // that is not being used (refcount == 0) and has been least recently
+ // used. The sort order defined
+ // for IndexInfo maintains this. See IndexInfo.compareTo().
+ IndexInfo info = Collections.min(indexInfos.values());
+ if (info.referenceCount != 0 || !info.isOpen) {
+ return false;
+ }
- info.index.deactivate();
- memoryUsed -= info.index.getMemoryAllocationSize();
- info.isOpen = false;
+ info.index.deactivate();
+ memoryUsed -= info.index.getMemoryAllocationSize();
+ info.isOpen = false;
- return true;
- }
+ return true;
+ }
- @Override
- public IIndex getIndex(long resourceID) {
- IndexInfo info = indexInfos.get(resourceID);
- return info == null ? null : info.index;
- }
+ @Override
+ public IIndex getIndex(long resourceID) {
+ IndexInfo info = indexInfos.get(resourceID);
+ return info == null ? null : info.index;
+ }
- @Override
- public void register(long resourceID, IIndex index) throws HyracksDataException {
- if (indexInfos.containsKey(resourceID)) {
- throw new HyracksDataException("Index with resource ID " + resourceID + " already exists.");
- }
+ @Override
+ public void register(long resourceID, IIndex index)
+ throws HyracksDataException {
+ if (indexInfos.containsKey(resourceID)) {
+ throw new HyracksDataException("Index with resource ID "
+ + resourceID + " already exists.");
+ }
- indexInfos.put(resourceID, new IndexInfo(index));
- }
+ indexInfos.put(resourceID, new IndexInfo(index));
+ }
- @Override
- public void unregister(long resourceID) throws HyracksDataException {
- IndexInfo info = indexInfos.remove(resourceID);
- if (info == null) {
- throw new HyracksDataException("Index with resource ID " + resourceID + " does not exist.");
- }
+ @Override
+ public void unregister(long resourceID) throws HyracksDataException {
+ IndexInfo info = indexInfos.remove(resourceID);
+ if (info == null) {
+ throw new HyracksDataException("Index with resource ID "
+ + resourceID + " does not exist.");
+ }
- if (info.referenceCount != 0) {
- indexInfos.put(resourceID, info);
- throw new HyracksDataException("Cannot remove index while it is open.");
- }
+ if (info.referenceCount != 0) {
+ indexInfos.put(resourceID, info);
+ throw new HyracksDataException(
+ "Cannot remove index while it is open.");
+ }
- if (info.isOpen) {
- info.index.deactivate();
- memoryUsed -= info.index.getMemoryAllocationSize();
- }
- }
+ if (info.isOpen) {
+ info.index.deactivate();
+ memoryUsed -= info.index.getMemoryAllocationSize();
+ }
+ }
- @Override
- public void open(long resourceID) throws HyracksDataException {
- IndexInfo info = indexInfos.get(resourceID);
- if (info == null) {
- throw new HyracksDataException("Failed to open index with resource ID " + resourceID
- + " since it does not exist.");
- }
+ @Override
+ public void open(long resourceID) throws HyracksDataException {
+ IndexInfo info = indexInfos.get(resourceID);
+ if (info == null) {
+ throw new HyracksDataException(
+ "Failed to open index with resource ID " + resourceID
+ + " since it does not exist.");
+ }
- long inMemorySize = info.index.getMemoryAllocationSize();
- while (memoryUsed + inMemorySize > memoryBudget) {
- if (!evictCandidateIndex()) {
- throw new HyracksDataException("Cannot activate index since memory budget would be exceeded.");
- }
- }
+ long inMemorySize = info.index.getMemoryAllocationSize();
+ while (memoryUsed + inMemorySize > memoryBudget) {
+ if (!evictCandidateIndex()) {
+ throw new HyracksDataException(
+ "Cannot activate index since memory budget would be exceeded.");
+ }
+ }
- if (!info.isOpen) {
- info.index.activate();
- info.isOpen = true;
- memoryUsed += inMemorySize;
- }
- info.touch();
- }
+ if (!info.isOpen) {
+ info.index.activate();
+ info.isOpen = true;
+ memoryUsed += inMemorySize;
+ }
+ info.touch();
+ }
- @Override
- public void close(long resourceID) {
- indexInfos.get(resourceID).untouch();
- }
+ @Override
+ public void close(long resourceID) {
+ indexInfos.get(resourceID).untouch();
+ }
- private class IndexInfo implements Comparable<IndexInfo> {
- private final IIndex index;
- private int referenceCount;
- private long lastAccess;
- private boolean isOpen;
+ private class IndexInfo implements Comparable<IndexInfo> {
+ private final IIndex index;
+ private int referenceCount;
+ private long lastAccess;
+ private boolean isOpen;
- public IndexInfo(IIndex index) {
- this.index = index;
- this.lastAccess = -1;
- this.referenceCount = 0;
- this.isOpen = false;
- }
+ public IndexInfo(IIndex index) {
+ this.index = index;
+ this.lastAccess = -1;
+ this.referenceCount = 0;
+ this.isOpen = false;
+ }
- public void touch() {
- lastAccess = System.currentTimeMillis();
- referenceCount++;
- }
+ public void touch() {
+ lastAccess = System.currentTimeMillis();
+ referenceCount++;
+ }
- public void untouch() {
- lastAccess = System.currentTimeMillis();
- referenceCount--;
- }
+ public void untouch() {
+ lastAccess = System.currentTimeMillis();
+ referenceCount--;
+ }
- @Override
- public int compareTo(IndexInfo i) {
- // sort by (isOpen, referenceCount, lastAccess) ascending, where true < false
- //
- // Example sort order:
- // -------------------
- // (F, 0, 70) <-- largest
- // (F, 0, 60)
- // (T, 10, 80)
- // (T, 10, 70)
- // (T, 9, 90)
- // (T, 0, 100) <-- smallest
- if (isOpen && !i.isOpen) {
- return -1;
- } else if (!isOpen && i.isOpen) {
- return 1;
- } else {
- if (referenceCount < i.referenceCount) {
- return -1;
- } else if (referenceCount > i.referenceCount) {
- return 1;
- } else {
- if (lastAccess < i.lastAccess) {
- return -1;
- } else if (lastAccess > i.lastAccess) {
- return 1;
- } else {
- return 0;
- }
- }
- }
+ @Override
+ public int compareTo(IndexInfo i) {
+ // sort by (isOpen, referenceCount, lastAccess) ascending, where
+ // true < false
+ //
+ // Example sort order:
+ // -------------------
+ // (F, 0, 70) <-- largest
+ // (F, 0, 60)
+ // (T, 10, 80)
+ // (T, 10, 70)
+ // (T, 9, 90)
+ // (T, 0, 100) <-- smallest
+ if (isOpen && !i.isOpen) {
+ return -1;
+ } else if (!isOpen && i.isOpen) {
+ return 1;
+ } else {
+ if (referenceCount < i.referenceCount) {
+ return -1;
+ } else if (referenceCount > i.referenceCount) {
+ return 1;
+ } else {
+ if (lastAccess < i.lastAccess) {
+ return -1;
+ } else if (lastAccess > i.lastAccess) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+ }
- }
+ }
- public String toString() {
- return "{index: " + index + ", isOpen: " + isOpen + ", refCount: " + referenceCount + ", lastAccess: "
- + lastAccess + "}";
- }
- }
+ public String toString() {
+ return "{index: " + index + ", isOpen: " + isOpen + ", refCount: "
+ + referenceCount + ", lastAccess: " + lastAccess + "}";
+ }
+ }
- @Override
- public List<IIndex> getOpenIndexes() {
- List<IIndex> openIndexes = new ArrayList<IIndex>();
- for (IndexInfo i : indexInfos.values()) {
- if (i.isOpen) {
- openIndexes.add(i.index);
- }
- }
- return openIndexes;
- }
+ @Override
+ public List<IIndex> getOpenIndexes() {
+ List<IIndex> openIndexes = new ArrayList<IIndex>();
+ for (IndexInfo i : indexInfos.values()) {
+ if (i.isOpen) {
+ openIndexes.add(i.index);
+ }
+ }
+ return openIndexes;
+ }
+
+ @Override
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void stop(boolean dumpState, OutputStream ouputStream) {
+ // TODO Auto-generated method stub
+
+ }
}
\ No newline at end of file
diff --git a/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/freepage/InMemoryBufferCache.java b/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/freepage/InMemoryBufferCache.java
index 66d8ec2..99fdb2e 100644
--- a/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/freepage/InMemoryBufferCache.java
+++ b/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/freepage/InMemoryBufferCache.java
@@ -15,6 +15,7 @@
package edu.uci.ics.hyracks.storage.am.lsm.common.freepage;
+import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@@ -203,4 +204,16 @@
public IFileMapProvider getFileMapProvider() {
return fileMapManager;
}
+
+ @Override
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void stop(boolean dumpState, OutputStream ouputStream) {
+ // TODO Auto-generated method stub
+
+ }
}
diff --git a/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/BufferCache.java b/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/BufferCache.java
index 03e46f5..f8195ab 100644
--- a/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/BufferCache.java
+++ b/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/BufferCache.java
@@ -14,6 +14,7 @@
*/
package edu.uci.ics.hyracks.storage.common.buffercache;
+import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
@@ -137,7 +138,8 @@
pinSanityCheck(dpid);
CachedPage cPage = findPage(dpid, newPage);
if (!newPage) {
- // Resolve race of multiple threads trying to read the page from disk.
+ // Resolve race of multiple threads trying to read the page from
+ // disk.
synchronized (cPage) {
if (!cPage.valid) {
read(cPage);
@@ -157,7 +159,8 @@
CachedPage cPage = null;
/*
- * Hash dpid to get a bucket and then check if the page exists in the bucket.
+ * Hash dpid to get a bucket and then check if the page exists in
+ * the bucket.
*/
int hash = hash(dpid);
CacheBucket bucket = pageMap[hash];
@@ -175,29 +178,38 @@
bucket.bucketLock.unlock();
}
/*
- * If we got here, the page was not in the hash table. Now we ask the page replacement strategy to find us a victim.
+ * If we got here, the page was not in the hash table. Now we ask
+ * the page replacement strategy to find us a victim.
*/
CachedPage victim = (CachedPage) pageReplacementStrategy.findVictim();
if (victim != null) {
/*
- * We have a victim with the following invariants.
- * 1. The dpid on the CachedPage may or may not be valid.
- * 2. We have a pin on the CachedPage. We have to deal with three cases here.
- * Case 1: The dpid on the CachedPage is invalid (-1). This indicates that this buffer has never been used.
- * So we are the only ones holding it. Get a lock on the required dpid's hash bucket, check if someone inserted
- * the page we want into the table. If so, decrement the pincount on the victim and return the winner page in the
- * table. If such a winner does not exist, insert the victim and return it.
- * Case 2: The dpid on the CachedPage is valid.
- * Case 2a: The current dpid and required dpid hash to the same bucket.
- * Get the bucket lock, check that the victim is still at pinCount == 1 If so check if there is a winning
- * CachedPage with the required dpid. If so, decrement the pinCount on the victim and return the winner.
- * If not, update the contents of the CachedPage to hold the required dpid and return it. If the picCount
- * on the victim was != 1 or CachedPage was dirty someone used the victim for its old contents -- Decrement
- * the pinCount and retry.
- * Case 2b: The current dpid and required dpid hash to different buckets. Get the two bucket locks in the order
- * of the bucket indexes (Ordering prevents deadlocks). Check for the existence of a winner in the new bucket
- * and for potential use of the victim (pinCount != 1). If everything looks good, remove the CachedPage from
- * the old bucket, and add it to the new bucket and update its header with the new dpid.
+ * We have a victim with the following invariants. 1. The dpid
+ * on the CachedPage may or may not be valid. 2. We have a pin
+ * on the CachedPage. We have to deal with three cases here.
+ * Case 1: The dpid on the CachedPage is invalid (-1). This
+ * indicates that this buffer has never been used. So we are the
+ * only ones holding it. Get a lock on the required dpid's hash
+ * bucket, check if someone inserted the page we want into the
+ * table. If so, decrement the pincount on the victim and return
+ * the winner page in the table. If such a winner does not
+ * exist, insert the victim and return it. Case 2: The dpid on
+ * the CachedPage is valid. Case 2a: The current dpid and
+ * required dpid hash to the same bucket. Get the bucket lock,
+ * check that the victim is still at pinCount == 1 If so check
+ * if there is a winning CachedPage with the required dpid. If
+ * so, decrement the pinCount on the victim and return the
+ * winner. If not, update the contents of the CachedPage to hold
+ * the required dpid and return it. If the picCount on the
+ * victim was != 1 or CachedPage was dirty someone used the
+ * victim for its old contents -- Decrement the pinCount and
+ * retry. Case 2b: The current dpid and required dpid hash to
+ * different buckets. Get the two bucket locks in the order of
+ * the bucket indexes (Ordering prevents deadlocks). Check for
+ * the existence of a winner in the new bucket and for potential
+ * use of the victim (pinCount != 1). If everything looks good,
+ * remove the CachedPage from the old bucket, and add it to the
+ * new bucket and update its header with the new dpid.
*/
if (victim.dpid < 0) {
/*
@@ -630,7 +642,8 @@
}
fileInfoMap.remove(entryFileId);
unreferencedFileFound = true;
- // for-each iterator is invalid because we changed fileInfoMap
+ // for-each iterator is invalid because we changed
+ // fileInfoMap
break;
}
}
@@ -764,7 +777,7 @@
} finally {
fileMapManager.unregisterFile(fileId);
if (fInfo != null) {
- // Mark the fInfo as deleted,
+ // Mark the fInfo as deleted,
// such that when its pages are reclaimed in openFile(),
// the pages are not flushed to disk but only invalidated.
if (!fInfo.fileHasBeenDeleted()) {
@@ -775,4 +788,16 @@
}
}
}
+
+ @Override
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void stop(boolean dumpState, OutputStream ouputStream) {
+ // TODO Auto-generated method stub
+
+ }
}
\ No newline at end of file
diff --git a/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/DebugBufferCache.java b/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/DebugBufferCache.java
index 13f7d52..0a43b1f 100644
--- a/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/DebugBufferCache.java
+++ b/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/DebugBufferCache.java
@@ -15,6 +15,7 @@
package edu.uci.ics.hyracks.storage.common.buffercache;
+import java.io.OutputStream;
import java.util.concurrent.atomic.AtomicLong;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
@@ -165,4 +166,16 @@
public void force(int fileId, boolean metadata) throws HyracksDataException {
bufferCache.force(fileId, metadata);
}
+
+ @Override
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void stop(boolean dumpState, OutputStream ouputStream) {
+ // TODO Auto-generated method stub
+
+ }
}
diff --git a/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/IBufferCache.java b/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/IBufferCache.java
index e8b407e..3c9882f 100644
--- a/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/IBufferCache.java
+++ b/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/IBufferCache.java
@@ -16,8 +16,9 @@
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.api.io.FileReference;
+import edu.uci.ics.hyracks.api.lifecycle.ILifeCycleComponent;
-public interface IBufferCache {
+public interface IBufferCache extends ILifeCycleComponent {
public void createFile(FileReference fileRef) throws HyracksDataException;
public void openFile(int fileId) throws HyracksDataException;