private final String defaultAppConfigFileName;
private final String appConfigBindingClassName;
private final String appConfigListKeyValue;
+ private final UpdateStrategy appConfigUpdateStrategy;
private final AtomicBoolean readingInitialAppConfig = new AtomicBoolean(true);
private volatile BindingContext bindingContext;
public DataStoreAppConfigMetadata(@Nonnull String id, @Nonnull String appConfigBindingClassName,
@Nullable String appConfigListKeyValue, @Nullable String defaultAppConfigFileName,
- @Nullable Element defaultAppConfigElement) {
+ @Nonnull UpdateStrategy updateStrategyValue, @Nullable Element defaultAppConfigElement) {
super(id);
this.defaultAppConfigElement = defaultAppConfigElement;
this.defaultAppConfigFileName = defaultAppConfigFileName;
this.appConfigBindingClassName = appConfigBindingClassName;
this.appConfigListKeyValue = appConfigListKeyValue;
+ this.appConfigUpdateStrategy = updateStrategyValue;
}
@Override
if(!setInitialAppConfig(Optional.of(newAppConfig)) &&
!Objects.equals(currentAppConfig, newAppConfig)) {
- LOG.debug("App config was updated - scheduling container for restart");
+ LOG.debug("App config was updated");
- restartContainer();
+ if(appConfigUpdateStrategy == UpdateStrategy.RELOAD) {
+ restartContainer();
+ }
}
} else if(type == ModificationType.DELETE) {
- LOG.debug("App config was deleted - scheduling container for restart");
+ LOG.debug("App config was deleted");
- restartContainer();
+ if(appConfigUpdateStrategy == UpdateStrategy.RELOAD) {
+ restartContainer();
+ }
}
}
}
static final String RPC_REGISTRY_NAME = "org.opendaylight.blueprint.RpcRegistry";
static final String NOTIFICATION_SERVICE_NAME = "org.opendaylight.blueprint.NotificationService";
static final String TYPE_ATTR = "type";
+ static final String UPDATE_STRATEGY_ATTR = "update-strategy";
private static final Logger LOG = LoggerFactory.getLogger(OpendaylightNamespaceHandler.class);
private static final String COMPONENT_PROCESSOR_NAME = ComponentProcessor.class.getName();
return new DataStoreAppConfigMetadata(getId(context, element), element.getAttribute(
DataStoreAppConfigMetadata.BINDING_CLASS), element.getAttribute(
DataStoreAppConfigMetadata.LIST_KEY_VALUE), element.getAttribute(
- DataStoreAppConfigMetadata.DEFAULT_CONFIG_FILE_NAME), defaultAppConfigElement);
+ DataStoreAppConfigMetadata.DEFAULT_CONFIG_FILE_NAME), parseUpdateStrategy(
+ element.getAttribute(UPDATE_STRATEGY_ATTR)), defaultAppConfigElement);
+ }
+
+ private UpdateStrategy parseUpdateStrategy(String updateStrategyValue) {
+ if (Strings.isNullOrEmpty(updateStrategyValue) ||
+ updateStrategyValue.equalsIgnoreCase(UpdateStrategy.RELOAD.name())) {
+ return UpdateStrategy.RELOAD;
+ } else if(updateStrategyValue.equalsIgnoreCase(UpdateStrategy.NONE.name())){
+ return UpdateStrategy.NONE;
+ } else {
+ LOG.warn("update-strategy {} not supported, using reload", updateStrategyValue);
+ return UpdateStrategy.RELOAD;
+ }
}
private Metadata parseSpecificReferenceList(Element element, ParserContext context) {
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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.blueprint.ext;
+
+/**
+ * Enumerates possible strategies when a component is updated
+ *
+ * @author Vishal Thapar
+ */
+public enum UpdateStrategy {
+ /*
+ * Restart container
+ */
+ RELOAD,
+ /*
+ * Don't do anything
+ */
+ NONE
+}
<xsd:attribute name="list-key-value" type="xsd:string" use="optional"/>
<xsd:attribute name="default-config-file-name" type="xsd:string" use="optional"/>
<xsd:attribute name="id" type="xsd:ID" use="required"/>
+ <xsd:attribute name="update-strategy" type="TupdateStrategy" use="optional" default="reload"/>
</xsd:complexType>
<xsd:element name="clustered-app-config" type="TclusteredAppConfig"/>
-
+ <xsd:simpleType name="TupdateStrategy">
+ <xsd:restriction base="xsd:NMTOKEN">
+ <xsd:enumeration value="none"/>
+ <xsd:enumeration value="reload"/>
+ </xsd:restriction>
+ </xsd:simpleType>
<xsd:complexType name="TspecificReferenceList">
<xsd:attribute name="interface" type="bp:Tclass" use="required"/>
<xsd:attribute name="id" type="xsd:ID"/>