Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Calcium integration #1860

Merged
merged 7 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private LightyController initController(final ControllerConfiguration config) th

private CommunityRestConf initRestconf(final RestConfConfiguration config, final LightyServices services) {
final RestConfConfiguration conf = RestConfConfigUtils.getRestConfConfiguration(config, services);
return CommunityRestConfBuilder.from(conf).withScheduledThreadPool(services.getScheduledThreadPool()).build();
return CommunityRestConfBuilder.from(conf).build();
}

private GnmiSouthboundModule initGnmiModule(final LightyServices services,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ private CommunityRestConf initRestconf(final RestConfConfiguration rcConfig, fin

return CommunityRestConfBuilder.from(restConfConfiguration)
.withLightyServer(jettyServerBuilder)
.withScheduledThreadPool(services.getScheduledThreadPool())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.xml.MissingNameSpaceException;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlUtil;
import org.opendaylight.yangtools.yang.common.QName;
Expand Down Expand Up @@ -91,20 +90,15 @@ public static Optional<? extends NotificationDefinition> loadNotification(
* @return {@link QName} for input data or empty.
*/
public static Optional<QName> getRpcQName(final XmlElement xmlElement) {
String optionalNamespace = null;
try {
optionalNamespace = xmlElement.getNamespace();
} catch (MissingNameSpaceException e) {
throw new RuntimeException(e);
}
String nxmlNamespace = xmlElement.namespace();
String name = xmlElement.getName();
if (Strings.isNullOrEmpty(name)) {
return Optional.empty();
}
String revision = null;
String namespace;
if (optionalNamespace != null) {
String[] split = optionalNamespace.split("\\?");
if (nxmlNamespace != null) {
String[] split = nxmlNamespace.split("\\?");
if (split.length > 1 && split[1].contains("revision=")) {
revision = split[1].replace("revision=", "");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
import org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.codec.gson.JsonParserStream;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.impl.schema.NormalizationResultHolder;
import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
Expand Down Expand Up @@ -160,8 +160,8 @@ public Writer serializeRpc(final Inference inference,
public NormalizedNode deserialize(final Inference inference, final Reader inputData)
throws DeserializationException {
if (inference.statementPath().isEmpty()) {
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> resultBuilder = Builders.containerBuilder()
.withNodeIdentifier(NodeIdentifier.create(SchemaContext.NAME));
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> resultBuilder =
ImmutableNodes.newContainerBuilder().withNodeIdentifier(NodeIdentifier.create(SchemaContext.NAME));
parseToResult(ImmutableNormalizedNodeStreamWriter.from(resultBuilder), inputData, inference);
return resultBuilder.build();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.spi.node.impl.ImmutableContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.spi.node.impl.ImmutableMapEntryNodeBuilder;
import org.opendaylight.yangtools.yang.data.spi.node.impl.ImmutableSystemMapNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.parser.api.YangParserException;
import org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory;
Expand Down Expand Up @@ -124,7 +121,7 @@ private static List<YangModuleInfo> loadModuleInfos() {
}

private static NormalizedNode topLevelContainerNode() {
return new ImmutableContainerNodeBuilder().withNodeIdentifier(NodeIdentifier.create(Toaster.QNAME))
return ImmutableNodes.newContainerBuilder().withNodeIdentifier(NodeIdentifier.create(Toaster.QNAME))
.withValue(List.of(
ImmutableNodes.leafNode(
NodeIdentifier.create(qOfToasterModel("toasterManufacturer")), "manufacturer"),
Expand All @@ -136,31 +133,31 @@ private static NormalizedNode topLevelContainerNode() {
}

private static NormalizedNode rpcLeafInputNode() {
return new ImmutableContainerNodeBuilder()
return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NodeIdentifier.create(SimpleInputOutputRpcInput.QNAME))
.withChild(ImmutableNodes.leafNode(
NodeIdentifier.create(qOfTestModel("input-obj")), "testValue"))
.build();
}

private static NormalizedNode rpcLeafOutputNode() {
return new ImmutableContainerNodeBuilder()
return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NodeIdentifier.create(SimpleInputOutputRpcOutput.QNAME))
.withChild(ImmutableNodes.leafNode(
NodeIdentifier.create(qOfTestModel("output-obj")), "testValue"))
.build();
}

private static NormalizedNode notificationContainer() {
return new ImmutableContainerNodeBuilder()
return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NodeIdentifier.create(ToasterRestocked.QNAME))
.withChild(ImmutableNodes.leafNode(
NodeIdentifier.create(qOfToasterModel("amountOfBread")), 1)).build();
}

private static NormalizedNode listEntryNode() {
final QName key = qOfTestModel("name");
return new ImmutableMapEntryNodeBuilder()
return ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(
SampleList.QNAME, key, "nameValue"))
.withValue(List.of(
Expand All @@ -171,12 +168,12 @@ private static NormalizedNode listEntryNode() {
}

private static NormalizedNode listNode() {
return new ImmutableSystemMapNodeBuilder().withNodeIdentifier(new NodeIdentifier(SampleList.QNAME))
return ImmutableNodes.newSystemMapBuilder().withNodeIdentifier(new NodeIdentifier(SampleList.QNAME))
.withChild((MapEntryNode) listEntryNode()).build();
}

private static NormalizedNode innerContainerNode() {
return new ImmutableContainerNodeBuilder().withNodeIdentifier(NodeIdentifier.create(SampleContainer.QNAME))
return ImmutableNodes.newContainerBuilder().withNodeIdentifier(NodeIdentifier.create(SampleContainer.QNAME))
.withValue(List.of(
org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes.leafNode(
NodeIdentifier.create(qOfTestModel("name")), "name")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
import org.opendaylight.yangtools.yang.parser.api.YangParserException;
Expand Down Expand Up @@ -166,82 +166,82 @@ public void testDeserializeListMultipleEntries() throws DeserializationException
}

private static NormalizedNode expectedToasterContainerNN() {
return wrapWithBaseContainer(Builders.containerBuilder()
return wrapWithBaseContainer(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NodeIdentifier.create(Toaster.QNAME))
.withChild(Builders.leafBuilder()
.withChild(ImmutableNodes.newLeafBuilder()
.withNodeIdentifier(NodeIdentifier.create(qOfToasterModel("toasterManufacturer")))
.withValue("manufacturer")
.build())
.withChild((Builders.leafBuilder()
.withChild((ImmutableNodes.newLeafBuilder()
.withNodeIdentifier(NodeIdentifier.create(qOfToasterModel("toasterStatus")))
.withValue("up")
.build()))
.withChild((Builders.leafBuilder()
.withChild((ImmutableNodes.newLeafBuilder()
.withNodeIdentifier(NodeIdentifier.create(qOfToasterModel("darknessFactor")))
.withValue(Uint32.valueOf(201392110))
.build()))
.build());
}

private static NormalizedNode expectedRpcInputNN() {
return Builders.containerBuilder()
return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NodeIdentifier.create(SimpleInputOutputRpcInput.QNAME))
.withChild(Builders.leafBuilder()
.withChild(ImmutableNodes.newLeafBuilder()
.withNodeIdentifier(NodeIdentifier.create(qOfTestModel("input-obj")))
.withValue("a")
.build())
.build();
}

private static NormalizedNode expectedRpcOutputNN() {
return Builders.containerBuilder()
return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NodeIdentifier.create(SimpleInputOutputRpcOutput.QNAME))
.withChild(Builders.leafBuilder()
.withChild(ImmutableNodes.newLeafBuilder()
.withNodeIdentifier(NodeIdentifier.create(qOfTestModel("output-obj")))
.withValue("a")
.build())
.build();
}

private static NormalizedNode expectedRpcContainerInputNN() {
return Builders.containerBuilder()
return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NodeIdentifier.create(ContainerIoRpcInput.QNAME))
.withChild(expectedInnerContainerNN())
.build();
}

private static NormalizedNode expectedTopLevelContainerNN() {
return wrapWithBaseContainer(Builders.containerBuilder()
return wrapWithBaseContainer(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NodeIdentifier.create(TopLevelContainer.QNAME))
.withChild(expectedInnerContainerNN())
.build());
}

private static DataContainerChild expectedInnerContainerNN() {
return Builders.containerBuilder()
return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NodeIdentifier.create(SampleContainer.QNAME))
.withChild(expectedInnerLeafNN())
.withChild((Builders.leafBuilder()
.withChild((ImmutableNodes.newLeafBuilder()
.withNodeIdentifier(NodeIdentifier.create(qOfTestModel("value")))
.withValue(Uint32.valueOf(1))
.build()))
.build();
}

private static DataContainerChild expectedInnerLeafNN() {
return Builders.leafBuilder()
return ImmutableNodes.newLeafBuilder()
.withNodeIdentifier(NodeIdentifier.create(qOfTestModel("name")))
.withValue("name")
.build();
}

private static NormalizedNode expectedListSingleEntryNN() {
return wrapWithBaseContainer(Builders.mapBuilder()
return wrapWithBaseContainer(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(NodeIdentifier.create(SampleList.QNAME))
.withChild(Builders.mapEntryBuilder()
.withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(SampleList.QNAME,
qOfTestModel("name"), "test"))
.withChild(Builders.leafBuilder()
.withChild(ImmutableNodes.newLeafBuilder()
.withNodeIdentifier(NodeIdentifier.create(qOfTestModel("name")))
.withValue("test")
.build())
Expand All @@ -250,12 +250,12 @@ private static NormalizedNode expectedListSingleEntryNN() {
}

private static NormalizedNode expectedTestListNN() {
return Builders.mapBuilder()
return ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(NodeIdentifier.create(TestList.QNAME))
.withChild(Builders.mapEntryBuilder()
.withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(TestList.QNAME,
qOfTestModel("test-name"), "test"))
.withChild(Builders.leafBuilder()
.withChild(ImmutableNodes.newLeafBuilder()
.withNodeIdentifier(NodeIdentifier.create(qOfTestModel("test-name")))
.withValue("test")
.build())
Expand All @@ -264,20 +264,20 @@ private static NormalizedNode expectedTestListNN() {
}

private static NormalizedNode expectedListMultipleEntriesNN() {
return wrapWithBaseContainer(Builders.mapBuilder()
return wrapWithBaseContainer(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(NodeIdentifier.create(SampleList.QNAME))
.withChild(Builders.mapEntryBuilder()
.withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(SampleList.QNAME,
qOfTestModel("name"), "test"))
.withChild(Builders.leafBuilder()
.withChild(ImmutableNodes.newLeafBuilder()
.withNodeIdentifier(NodeIdentifier.create(qOfTestModel("name")))
.withValue("test")
.build())
.build())
.withChild(Builders.mapEntryBuilder()
.withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(SampleList.QNAME,
qOfTestModel("name"), "test2"))
.withChild(Builders.leafBuilder()
.withChild(ImmutableNodes.newLeafBuilder()
.withNodeIdentifier(NodeIdentifier.create(qOfTestModel("name")))
.withValue("test2")
.build())
Expand All @@ -286,7 +286,7 @@ private static NormalizedNode expectedListMultipleEntriesNN() {
}

private static NormalizedNode wrapWithBaseContainer(final DataContainerChild child) {
return Builders.containerBuilder()
return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NodeIdentifier.create(SchemaContext.NAME))
.withChild(child)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
import io.lighty.core.controller.api.LightyServices;
import io.netty.channel.EventLoopGroup;
import io.netty.util.Timer;
import io.netty.util.concurrent.EventExecutor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import org.opendaylight.controller.cluster.ActorSystemProvider;
import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
import org.opendaylight.controller.cluster.datastore.admin.ClusterAdminRpcService;
Expand Down Expand Up @@ -65,8 +62,6 @@ protected void configure() {
.toInstance(lightyServices.getActorSystemProvider());
bind(DOMSchemaService.class)
.toInstance(lightyServices.getDOMSchemaService());
bind(DOMSchemaService.YangTextSourceExtension.class)
.toInstance(lightyServices.getYangTextSourceExtension());
bind(DOMNotificationRouter.class)
.toInstance(lightyServices.getDOMNotificationRouter());
bind(DistributedDataStoreInterface.class)
Expand All @@ -87,18 +82,12 @@ protected void configure() {
.toInstance(lightyServices.getClusterAdminRPCService());
bind(ClusterSingletonServiceProvider.class)
.toInstance(lightyServices.getClusterSingletonServiceProvider());
bind(EventExecutor.class)
.toInstance(lightyServices.getEventExecutor());
bind(EventLoopGroup.class)
.annotatedWith(Names.named("BossGroup"))
.toInstance(lightyServices.getBossGroup());
bind(EventLoopGroup.class)
.annotatedWith(Names.named("WorkerGroup"))
.toInstance(lightyServices.getWorkerGroup());
bind(ExecutorService.class)
.toInstance(lightyServices.getThreadPool());
bind(ScheduledExecutorService.class)
.toInstance(lightyServices.getScheduledThreadPool());
bind(Timer.class)
.toInstance(lightyServices.getTimer());
bind(DOMMountPointService.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ public void testDIDomSchemaService() {
assertNotNull(testService.getDomSchemaService());
}

@Test
public void testDIDomYangTextSourceProvider() {
assertNotNull(testService.getDomYangTextSourceProvider());
}

@Test
public void testDIDomNotificationSubscriptionListenerRegistry() {
assertNotNull(testService.getDomNotificationSubscriptionListenerRegistry());
Expand Down Expand Up @@ -127,11 +122,6 @@ public void testDIClusterSingletonServiceProvider() {
assertNotNull(testService.getClusterSingletonServiceProvider());
}

@Test
public void testDIEventExecutor() {
assertNotNull(testService.getEventExecutor());
}

@Test
public void testDIEventLoopGroupBoss() {
assertNotNull(testService.getEventLoopGroupBoss());
Expand All @@ -142,16 +132,6 @@ public void testDIEventLoopGroupWorker() {
assertNotNull(testService.getEventLoopGroupWorker());
}

@Test
public void testDIThreadPool() {
assertNotNull(testService.getThreadPool());
}

@Test
public void testDIScheduledThreadPool() {
assertNotNull(testService.getScheduledThreadPool());
}

@Test
public void testDITimer() {
assertNotNull(testService.getTimer());
Expand Down
Loading
Loading