Skip to content

Commit f56caa8

Browse files
author
Wang, Gang(Gary)
committed
MNEMONIC-224: Create a Mnemonic-sessions module
MNEMONIC-223: Abstract MneSessions from Mnemonic-hadoop module
1 parent 224ef2f commit f56caa8

File tree

13 files changed

+649
-307
lines changed

13 files changed

+649
-307
lines changed

build-tools/source-assembly.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<includes>
3636
<include>org.apache.mnemonic:mnemonic-core</include>
3737
<include>org.apache.mnemonic:mnemonic-collections</include>
38+
<include>org.apache.mnemonic:mnemonic-sessions</include>
3839
<include>org.apache.mnemonic:mnemonic-examples</include>
3940
</includes>
4041
<sources>

mnemonic-hadoop/mnemonic-hadoop-mapreduce/src/main/java/org/apache/mnemonic/hadoop/MneDurableInputSession.java

Lines changed: 3 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,20 @@
1818

1919
package org.apache.mnemonic.hadoop;
2020

21-
import java.util.Iterator;
22-
2321
import org.apache.hadoop.conf.Configuration;
2422
import org.apache.hadoop.fs.Path;
2523
import org.apache.hadoop.mapreduce.TaskAttemptContext;
2624
import org.apache.mnemonic.ConfigurationException;
2725
import org.apache.mnemonic.DurableType;
28-
import org.apache.mnemonic.EntityFactoryProxy;
2926
import org.apache.mnemonic.NonVolatileMemAllocator;
3027
import org.apache.mnemonic.Utils;
31-
import org.apache.mnemonic.collections.DurableSinglyLinkedList;
32-
import org.apache.mnemonic.collections.DurableSinglyLinkedListFactory;
28+
import org.apache.mnemonic.sessions.DurableInputSession;
3329

3430
public class MneDurableInputSession<V>
35-
implements MneInputSession<V>, MneDurableComputable<NonVolatileMemAllocator> {
31+
extends DurableInputSession<V, NonVolatileMemAllocator> {
3632

3733
private TaskAttemptContext taskAttemptContext;
3834
private Configuration configuration;
39-
private String serviceName;
40-
private DurableType[] durableTypes;
41-
private EntityFactoryProxy[] entityFactoryProxies;
42-
private long slotKeyId;
43-
44-
protected long m_handler;
45-
protected NonVolatileMemAllocator m_act;
46-
4735

4836
public MneDurableInputSession(TaskAttemptContext taskAttemptContext) {
4937
this(taskAttemptContext.getConfiguration());
@@ -59,13 +47,12 @@ public void validateConfig() {
5947
throw new ConfigurationException("The durable type of record parameters does not exist");
6048
} else {
6149
if (DurableType.DURABLE == getDurableTypes()[0]
62-
&& getEntityFactoryProxies().length < 1) { /* T.B.D. BUFFER & CHUNK */
50+
&& getEntityFactoryProxies().length < 1) {
6351
throw new ConfigurationException("The durable entity proxy of record parameters does not exist");
6452
}
6553
}
6654
}
6755

68-
@Override
6956
public void readConfig(String prefix) {
7057
Configuration conf = getConfiguration();
7158
if (conf == null) {
@@ -79,28 +66,12 @@ public void readConfig(String prefix) {
7966
validateConfig();
8067
}
8168

82-
@Override
8369
public void initialize(Path path) {
8470
m_act = new NonVolatileMemAllocator(Utils.getNonVolatileMemoryAllocatorService(getServiceName()), 1024000L,
8571
path.toString(), true);
8672
m_handler = m_act.getHandler(getSlotKeyId());
8773
}
8874

89-
@Override
90-
public Iterator<V> iterator() {
91-
Iterator<V> iter;
92-
DurableSinglyLinkedList<V> dsllist;
93-
dsllist = DurableSinglyLinkedListFactory.restore(m_act, getEntityFactoryProxies(), getDurableTypes(), m_handler,
94-
false);
95-
iter = dsllist.iterator();
96-
return iter;
97-
}
98-
99-
@Override
100-
public void close() {
101-
m_act.close();
102-
}
103-
10475
public TaskAttemptContext getTaskAttemptContext() {
10576
return taskAttemptContext;
10677
}
@@ -109,48 +80,6 @@ public void setTaskAttemptContext(TaskAttemptContext taskAttemptContext) {
10980
this.taskAttemptContext = taskAttemptContext;
11081
}
11182

112-
public String getServiceName() {
113-
return serviceName;
114-
}
115-
116-
public void setServiceName(String serviceName) {
117-
this.serviceName = serviceName;
118-
}
119-
120-
public DurableType[] getDurableTypes() {
121-
return durableTypes;
122-
}
123-
124-
public void setDurableTypes(DurableType[] durableTypes) {
125-
this.durableTypes = durableTypes;
126-
}
127-
128-
public EntityFactoryProxy[] getEntityFactoryProxies() {
129-
return entityFactoryProxies;
130-
}
131-
132-
public void setEntityFactoryProxies(EntityFactoryProxy[] entityFactoryProxies) {
133-
this.entityFactoryProxies = entityFactoryProxies;
134-
}
135-
136-
public long getSlotKeyId() {
137-
return slotKeyId;
138-
}
139-
140-
public void setSlotKeyId(long slotKeyId) {
141-
this.slotKeyId = slotKeyId;
142-
}
143-
144-
@Override
145-
public NonVolatileMemAllocator getAllocator() {
146-
return m_act;
147-
}
148-
149-
@Override
150-
public long getHandler() {
151-
return m_handler;
152-
}
153-
15483
public Configuration getConfiguration() {
15584
return configuration;
15685
}

0 commit comments

Comments
 (0)