import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map.Entry;
-import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import org.opendaylight.mdsal.common.api.ReadFailedException;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
void apply(final DOMDataTreeWriteCursor cursor, final YangInstanceIdentifier path,
final NormalizedNode<?, ?> data) {
int enterCount = 0;
- Iterator<PathArgument> it = path.getPathArguments().iterator();
+ final Iterator<PathArgument> it = path.getPathArguments().iterator();
while (it.hasNext()) {
- PathArgument currentArg = it.next();
+ final PathArgument currentArg = it.next();
if (it.hasNext()) {
// We need to enter one level deeper, we are not at leaf (modified) node
cursor.enter(currentArg);
private final ShardDataModification modification;
private DOMDataTreeWriteCursor cursor;
- private DataTree rootShardDataTree;
+ private final DataTree rootShardDataTree;
private DataTreeModification rootModification = null;
- private ArrayList<DOMStoreThreePhaseCommitCohort> cohorts = new ArrayList<>();
- private InMemoryDOMDataTreeShardChangePublisher changePublisher;
+ private final ArrayList<DOMStoreThreePhaseCommitCohort> cohorts = new ArrayList<>();
+ private final InMemoryDOMDataTreeShardChangePublisher changePublisher;
private boolean finished = false;
// FIXME inject into shard?
- private ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
+ private final ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
InmemoryDOMDataTreeShardWriteTransaction(final ShardDataModification root,
final DataTree rootShardDataTree,
}
void delete(final YangInstanceIdentifier path) {
- YangInstanceIdentifier relativePath = toRelative(path);
+ final YangInstanceIdentifier relativePath = toRelative(path);
Preconditions.checkArgument(!YangInstanceIdentifier.EMPTY.equals(relativePath),
"Deletion of shard root is not allowed");
SimpleCursorOperation.DELETE.apply(getCursor(), relativePath , null);
}
private YangInstanceIdentifier toRelative(final YangInstanceIdentifier path) {
- Optional<YangInstanceIdentifier> relative =
+ final Optional<YangInstanceIdentifier> relative =
path.relativeTo(modification.getPrefix().getRootIdentifier());
Preconditions.checkArgument(relative.isPresent());
return relative.get();
}
public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
- // FIXME: Implement this
- return null;
+ throw new UnsupportedOperationException("Not implemented yet");
}
public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
- // TODO Auto-generated method stub
- return null;
- }
-
-
- public Object getIdentifier() {
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException("Not implemented yet");
}
@Override
public void close() {
Preconditions.checkState(!finished, "Attempting to close an already finished transaction.");
modification.closeTransactions();
- cursor.close();
+ if (cursor != null) {
+ cursor.close();
+ }
finished = true;
}
rootModification = modification.seal();
cohorts.add(new InMemoryDOMDataTreeShardThreePhaseCommitCohort(rootShardDataTree, rootModification, changePublisher));
- for (Entry<DOMDataTreeIdentifier, ForeignShardModificationContext> entry : modification.getChildShards().entrySet()) {
+ for (final Entry<DOMDataTreeIdentifier, ForeignShardModificationContext> entry : modification.getChildShards().entrySet()) {
cohorts.add(new ForeignShardThreePhaseCommitCohort(entry.getKey(), entry.getValue()));
}
finished = true;
public DOMDataTreeWriteCursor createCursor(final DOMDataTreeIdentifier prefix) {
Preconditions.checkState(!finished, "Transaction is finished/closed already.");
Preconditions.checkState(cursor == null, "Previous cursor wasn't closed");
- DOMDataTreeWriteCursor ret = getCursor();
- YangInstanceIdentifier relativePath = toRelative(prefix.getRootIdentifier());
+ final DOMDataTreeWriteCursor ret = getCursor();
+ final YangInstanceIdentifier relativePath = toRelative(prefix.getRootIdentifier());
ret.enter(relativePath.getPathArguments());
return ret;
}