blob: 74277930187e12bee69723cb6d3dd47bf35d9416 [file] [log] [blame]
/**
* 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.hadoop.hdfs.server.namenode;
import io.netty.buffer.ByteBuf;
import java.io.Closeable;
import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.Map;
import java.util.NavigableMap;
import static org.apache.hadoop.hdfs.server.namenode.INodeId.INVALID_INODE_ID;
abstract class Transaction implements Closeable {
protected final FSDirectory fsd;
protected Transaction(FSDirectory fsd) {
this.fsd = fsd;
}
abstract FlatINode getINode(long id);
abstract long getChild(long parentId, ByteBuffer localName);
abstract DBChildrenView childrenView(long parent);
protected FlatINode getINodeFromDB(long id) {
DB.INodeContainer c = fsd.db().getINode(id);
return c == null ? null : FlatINode.wrap(c.inode());
}
protected long getChildFromDB(long parentId, ByteBuffer localName) {
DB.INodeContainer c = fsd.db().getINode(parentId);
return c == null ? INVALID_INODE_ID : c.getChild(localName);
}
}