use of com.nokia.dempsy.util.Pair in project Dempsy by Dempsy.
the class LocalClusterSessionFactory method doormdir.
private static synchronized Pair<Entry, Entry> doormdir(String path) throws ClusterInfoException {
Entry ths = entries.get(path);
if (ths == null)
throw new ClusterInfoException("rmdir of non existant node \"" + path + "\"");
Entry parent = entries.get(parent(path));
entries.remove(path);
if (parent != null) {
int lastSlash = path.lastIndexOf('/');
parent.children.remove(path.substring(lastSlash + 1));
}
return new Pair<Entry, Entry>(ths, parent);
}
use of com.nokia.dempsy.util.Pair in project Dempsy by Dempsy.
the class LocalClusterSessionFactory method doomkdir.
private static synchronized Pair<Entry, String> doomkdir(String path, Object data, DirMode mode) throws ClusterInfoException {
if (oexists(path, null))
return new Pair<Entry, String>(null, null);
String parentPath = parent(path);
Entry parent = entries.get(parentPath);
if (parent == null) {
throw new ClusterInfoException("No Parent for \"" + path + "\" which is expected to be \"" + parent(path) + "\"");
}
long seq = -1;
if (mode.isSequential()) {
AtomicLong cseq = parent.childSequences.get(path);
if (cseq == null)
parent.childSequences.put(path, cseq = new AtomicLong(0));
seq = cseq.getAndIncrement();
}
String pathToUse = seq >= 0 ? (path + seq) : path;
entries.put(pathToUse, new Entry(data));
// find the relative path
int lastSlash = pathToUse.lastIndexOf('/');
parent.children.add(pathToUse.substring(lastSlash + 1));
return new Pair<Entry, String>(parent, pathToUse);
}
Aggregations