Add watchdog thread to detect illegal blocking calls during second phase commit.
[controller.git] / opendaylight / config / config-manager / src / main / java / org / opendaylight / controller / config / manager / impl / dependencyresolver / ModuleInternalTransactionalInfo.java
diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/ModuleInternalTransactionalInfo.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/ModuleInternalTransactionalInfo.java
new file mode 100644 (file)
index 0000000..e9f573a
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.manager.impl.dependencyresolver;
+
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.config.manager.impl.ModuleInternalInfo;
+import org.opendaylight.controller.config.manager.impl.dynamicmbean.DynamicReadableWrapper;
+import org.opendaylight.controller.config.manager.impl.jmx.TransactionModuleJMXRegistrator.TransactionModuleJMXRegistration;
+import org.opendaylight.controller.config.spi.Module;
+import org.opendaylight.controller.config.spi.ModuleFactory;
+import org.opendaylight.yangtools.concepts.Identifiable;
+
+import javax.annotation.Nullable;
+
+public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdentifier> {
+    private final ModuleIdentifier name;
+    private final Module proxiedModule, realModule;
+    private final ModuleFactory moduleFactory;
+    @Nullable
+    private final ModuleInternalInfo maybeOldInternalInfo;
+    private final TransactionModuleJMXRegistration transactionModuleJMXRegistration;
+    private final boolean isDefaultBean;
+
+    public ModuleInternalTransactionalInfo(ModuleIdentifier name, Module proxiedModule,
+                                           ModuleFactory moduleFactory,
+                                           ModuleInternalInfo maybeOldInternalInfo,
+                                           TransactionModuleJMXRegistration transactionModuleJMXRegistration,
+                                           boolean isDefaultBean, Module realModule) {
+        this.name = name;
+        this.proxiedModule = proxiedModule;
+        this.moduleFactory = moduleFactory;
+        this.maybeOldInternalInfo = maybeOldInternalInfo;
+        this.transactionModuleJMXRegistration = transactionModuleJMXRegistration;
+        this.isDefaultBean = isDefaultBean;
+        this.realModule = realModule;
+    }
+
+
+    public boolean hasOldModule() {
+        return maybeOldInternalInfo != null;
+    }
+
+    public DestroyedModule toDestroyedModule() {
+        if (maybeOldInternalInfo == null) {
+            throw new IllegalStateException("Cannot destroy uncommitted module");
+        }
+        DynamicReadableWrapper oldModule = maybeOldInternalInfo
+                .getReadableModule();
+        return new DestroyedModule(name, oldModule.getInstance(),
+                maybeOldInternalInfo.getModuleJMXRegistrator(),
+                maybeOldInternalInfo.getOsgiRegistration(),
+                maybeOldInternalInfo.getOrderingIdx());
+    }
+
+
+    public Module getProxiedModule() {
+        return proxiedModule;
+    }
+
+    public ModuleFactory getModuleFactory() {
+        return moduleFactory;
+    }
+
+    @Nullable
+    public ModuleInternalInfo getOldInternalInfo() {
+        if (maybeOldInternalInfo == null) {
+            throw new NullPointerException();
+        }
+        return maybeOldInternalInfo;
+    }
+
+    public TransactionModuleJMXRegistration getTransactionModuleJMXRegistration() {
+        return transactionModuleJMXRegistration;
+    }
+
+    @Override
+    public ModuleIdentifier getIdentifier() {
+        return name;
+    }
+
+    public boolean isDefaultBean() {
+        return isDefaultBean;
+    }
+
+    public Module getRealModule() {
+        return realModule;
+    }
+}