summaryrefslogtreecommitdiffstats
path: root/fib-management/fib-management-impl
diff options
context:
space:
mode:
authorMichal Cmarada <michal.cmarada@pantheon.tech>2018-06-20 09:57:15 +0200
committerMarek Gradzki <mgradzki@cisco.com>2018-06-22 11:28:50 +0000
commit72d39b9cf9eb93893e7871dcd7c61a4985e220aa (patch)
treef5342f20d27b1dd06bba240f79098811aed67519 /fib-management/fib-management-impl
parent942aecbb35a6ee1cfb27eb6ae293b6baa4de9148 (diff)
HC2VPP-317: remove FibTableService
After implementing FIB table management in SRv6 and routing FibTableService is no longer necessary and can be removed. Change-Id: I797ac52d5ed8ee1c6bf901895080aa06e5ac9016 Signed-off-by: Michal Cmarada <michal.cmarada@pantheon.tech>
Diffstat (limited to 'fib-management/fib-management-impl')
-rw-r--r--fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/FibManagementModule.java17
-rw-r--r--fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/services/FibTableService.java58
-rw-r--r--fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/services/FibTableServiceImpl.java110
-rw-r--r--fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/services/FibTableServiceProvider.java38
-rw-r--r--fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/services/FibTableServiceImplTest.java103
5 files changed, 0 insertions, 326 deletions
diff --git a/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/FibManagementModule.java b/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/FibManagementModule.java
index 462a1e4f6..b889c16a9 100644
--- a/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/FibManagementModule.java
+++ b/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/FibManagementModule.java
@@ -16,18 +16,12 @@
package io.fd.hc2vpp.fib.management;
-import com.google.common.annotations.VisibleForTesting;
import com.google.inject.AbstractModule;
-import com.google.inject.Provider;
-import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
import io.fd.hc2vpp.fib.management.read.FibManagementReaderFactory;
-import io.fd.hc2vpp.fib.management.services.FibTableService;
-import io.fd.hc2vpp.fib.management.services.FibTableServiceProvider;
import io.fd.hc2vpp.fib.management.write.FibManagementWriterFactory;
import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.write.WriterFactory;
-import javax.annotation.Nonnull;
import net.jmob.guice.conf.core.ConfigurationModule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,23 +32,12 @@ import org.slf4j.LoggerFactory;
public class FibManagementModule extends AbstractModule {
private static final Logger LOG = LoggerFactory.getLogger(FibManagementModule.class);
- private final Class<? extends Provider<FibTableService>> fibTableServiceProvider;
-
- public FibManagementModule() {
- this(FibTableServiceProvider.class);
- }
-
- @VisibleForTesting
- protected FibManagementModule(@Nonnull final Class<? extends Provider<FibTableService>> fibTableServiceProvider) {
- this.fibTableServiceProvider = fibTableServiceProvider;
- }
@Override
protected void configure() {
LOG.info("Starting FibManagementModule initialization");
// requests injection of properties
install(ConfigurationModule.create());
- bind(FibTableService.class).toProvider(fibTableServiceProvider).in(Singleton.class);
LOG.debug("Injecting FibManagementModule reader factories");
// creates reader factory binding
diff --git a/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/services/FibTableService.java b/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/services/FibTableService.java
deleted file mode 100644
index eef4df7fa..000000000
--- a/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/services/FibTableService.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
- *
- * Licensed 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 io.fd.hc2vpp.fib.management.services;
-
-import static java.lang.String.format;
-
-import io.fd.honeycomb.translate.ModificationCache;
-import io.fd.honeycomb.translate.read.ReadFailedException;
-import io.fd.honeycomb.translate.write.WriteFailedException;
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public interface FibTableService {
-
- /**
- * Checks whether FIB table with provided index exist in VPP
- *
- * @throws ReadFailedException if there was an error while reading FIB tables
- * @throws FibTableService.FibTableDoesNotExistException if requested index does not exist
- */
- void checkTableExist(@Nonnegative final int index, @Nonnull final ModificationCache cache)
- throws ReadFailedException, FibTableService.FibTableDoesNotExistException;
-
- /**
- * Writes FIB table in VPP
- *
- * @param identifier id of currently processed data
- * @param tableId table Id to be written in VPP
- * @param tableName name of the FIB table that will be added
- * @param isIpv6 true if adding IPv6 FIB table, false if adding IPv4 table
- * @throws WriteFailedException if there was an error while writing FIB tables
- */
- @Deprecated
- void write(InstanceIdentifier<?> identifier, @Nonnegative int tableId, @Nonnull String tableName, boolean isIpv6)
- throws WriteFailedException;
-
- class FibTableDoesNotExistException extends Exception {
-
- public FibTableDoesNotExistException(final int index) {
- super(format("Fib table with index %s does not exist", index));
- }
- }
-}
diff --git a/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/services/FibTableServiceImpl.java b/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/services/FibTableServiceImpl.java
deleted file mode 100644
index 01d264189..000000000
--- a/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/services/FibTableServiceImpl.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
- *
- * Licensed 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 io.fd.hc2vpp.fib.management.services;
-
-import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS;
-
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
-import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
-import io.fd.hc2vpp.fib.management.FibManagementIIds;
-import io.fd.hc2vpp.fib.management.request.FibTableRequest;
-import io.fd.honeycomb.translate.ModificationCache;
-import io.fd.honeycomb.translate.read.ReadFailedException;
-import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
-import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.vpp.jvpp.core.dto.Ip6FibDetailsReplyDump;
-import io.fd.vpp.jvpp.core.dto.Ip6FibDump;
-import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump;
-import io.fd.vpp.jvpp.core.dto.IpFibDump;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-import java.util.Collections;
-import java.util.stream.Stream;
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-// Todo HC2VPP-317: FibTableService was created as a temporary workaround to write Fib tables in VPP.
-// We need to implement proper support for Fib table management.
-public class FibTableServiceImpl extends FutureJVppCustomizer implements FibTableService, JvppReplyConsumer {
-
- private static final Logger LOG = LoggerFactory.getLogger(FibTableServiceImpl.class);
- private final DumpCacheManager<IpFibDetailsReplyDump, Void> v4DumpManager;
- private final DumpCacheManager<Ip6FibDetailsReplyDump, Void> v6DumpManager;
-
- public FibTableServiceImpl(@Nonnull FutureJVppCore futureJVppCore) {
- super(futureJVppCore);
- v4DumpManager = new DumpCacheManager.DumpCacheManagerBuilder<IpFibDetailsReplyDump, Void>()
- .acceptOnly(IpFibDetailsReplyDump.class)
- .withExecutor((identifier, params) -> getReplyForRead(
- futureJVppCore.ipFibDump(new IpFibDump()).toCompletableFuture(), identifier))
- .build();
- v6DumpManager = new DumpCacheManager.DumpCacheManagerBuilder<Ip6FibDetailsReplyDump, Void>()
- .acceptOnly(Ip6FibDetailsReplyDump.class)
- .withExecutor((identifier, params) -> getReplyForRead(
- futureJVppCore.ip6FibDump(new Ip6FibDump()).toCompletableFuture(), identifier))
- .build();
- }
-
- @Override
- public void write(InstanceIdentifier<?> identifier, @Nonnegative int tableId, @Nonnull String tableName,
- boolean isIpv6) throws WriteFailedException {
- // Register FIB table in VPP
- FibTableRequest fibTableRequest = new FibTableRequest(getFutureJVpp());
- fibTableRequest.setFibName(tableName);
- fibTableRequest.setIpv6(isIpv6);
- fibTableRequest.setFibTable(tableId);
- fibTableRequest.checkValid();
- try {
- fibTableRequest.write(identifier);
- LOG.debug("Fib table written successfully. table-name: {}, table-id: {}, request: {}", tableName, tableId,
- fibTableRequest);
- } catch (WriteFailedException e) {
- LOG.warn("Fib table write failed. request: {}", fibTableRequest);
- throw new WriteFailedException(identifier, "Failed to write FIB table to VPP.", e);
- }
- }
-
- @Override
- public void checkTableExist(@Nonnegative final int index, @Nonnull final ModificationCache cache)
- throws ReadFailedException, FibTableService.FibTableDoesNotExistException {
-
- if (Stream.concat(dumpV4FibTableIdsStream(cache), dumpV6FibTableIdsStream(cache))
- .noneMatch(id -> id == index)) {
- throw new FibTableService.FibTableDoesNotExistException(index);
- }
- }
-
- private Stream<Integer> dumpV6FibTableIdsStream(final ModificationCache cache) throws ReadFailedException {
- return v6DumpManager.getDump(FibManagementIIds.FIB_MNGMNT, cache, NO_PARAMS)
- .toJavaUtil()
- .map(ip6FibDetailsReplyDump -> ip6FibDetailsReplyDump.ip6FibDetails)
- .orElse(Collections.emptyList())
- .stream()
- .map(ip6FibDetails -> ip6FibDetails.tableId);
- }
-
- private Stream<Integer> dumpV4FibTableIdsStream(final ModificationCache cache) throws ReadFailedException {
- return v4DumpManager.getDump(FibManagementIIds.FIB_MNGMNT, cache, NO_PARAMS)
- .toJavaUtil()
- .map(ipFibDetailsReplyDump -> ipFibDetailsReplyDump.ipFibDetails)
- .orElse(Collections.emptyList())
- .stream()
- .map(ipFibDetails -> ipFibDetails.tableId);
- }
-}
diff --git a/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/services/FibTableServiceProvider.java b/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/services/FibTableServiceProvider.java
deleted file mode 100644
index d70f18e65..000000000
--- a/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/services/FibTableServiceProvider.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
- *
- * Licensed 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 io.fd.hc2vpp.fib.management.services;
-
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import io.fd.honeycomb.translate.ModificationCache;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-
-public class FibTableServiceProvider implements Provider<FibTableService> {
-
- @Inject
- private
- FutureJVppCore api;
-
- @Inject
- private ModificationCache modificationCache;
-
- @Override
- public FibTableService get() {
- return new FibTableServiceImpl(api);
- }
-}
diff --git a/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/services/FibTableServiceImplTest.java b/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/services/FibTableServiceImplTest.java
deleted file mode 100644
index 2351ead2c..000000000
--- a/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/services/FibTableServiceImplTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
- *
- * Licensed 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 io.fd.hc2vpp.fib.management.services;
-
-import static io.fd.vpp.jvpp.Assertions.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import com.google.inject.Inject;
-import io.fd.hc2vpp.common.test.util.FutureProducer;
-import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.fib.management.FibManagementIIds;
-import io.fd.hc2vpp.fib.management.helpers.SchemaContextTestHelper;
-import io.fd.honeycomb.translate.ModificationCache;
-import io.fd.honeycomb.translate.read.ReadFailedException;
-import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.vpp.jvpp.core.dto.Ip6FibDetailsReplyDump;
-import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump;
-import io.fd.vpp.jvpp.core.dto.IpTableAddDel;
-import io.fd.vpp.jvpp.core.dto.IpTableAddDelReply;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-public class FibTableServiceImplTest implements SchemaContextTestHelper, ByteDataTranslator, FutureProducer {
-
- private static final int FIB_TABLE_ID = 123456;
- private static final String FIB_TABLE_NAME = "VRF123456";
-
- @Inject
- @Mock
- private static FutureJVppCore api;
-
- @Mock
- private ModificationCache modificationCache;
-
- @Captor
- private ArgumentCaptor<IpTableAddDel> argumentCaptor;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- when(api.ipTableAddDel(any())).thenReturn(future(new IpTableAddDelReply()));
- when(api.ipFibDump(any())).thenReturn(future(new IpFibDetailsReplyDump()));
- when(api.ip6FibDump(any())).thenReturn(future(new Ip6FibDetailsReplyDump()));
- when(modificationCache.get(any())).thenReturn(null);
-
- }
-
- @Test(expected = FibTableService.FibTableDoesNotExistException.class)
- public void checkTableExistTest() throws ReadFailedException, FibTableService.FibTableDoesNotExistException {
- FibTableServiceImpl fibService = new FibTableServiceImpl(api);
- fibService.checkTableExist(FIB_TABLE_ID, modificationCache);
- }
-
- @Test
- public void writeIpv4Test() throws WriteFailedException {
- FibTableServiceImpl fibTableService = new FibTableServiceImpl(api);
- fibTableService.write(FibManagementIIds.FIB_MNGMNT, FIB_TABLE_ID, FIB_TABLE_NAME, false);
-
- verify(api, times(1)).ipTableAddDel(argumentCaptor.capture());
-
- assertTableAddDelRequest(argumentCaptor.getValue(), false);
- }
-
- @Test
- public void writeIpv6Test() throws WriteFailedException {
- FibTableServiceImpl fibTableService = new FibTableServiceImpl(api);
- fibTableService.write(FibManagementIIds.FIB_MNGMNT, FIB_TABLE_ID, FIB_TABLE_NAME, true);
-
- verify(api, times(1)).ipTableAddDel(argumentCaptor.capture());
-
- assertTableAddDelRequest(argumentCaptor.getValue(), true);
- }
-
- private void assertTableAddDelRequest(IpTableAddDel jvppRequest, boolean isIpv6) {
- assertEquals(ByteDataTranslator.BYTE_TRUE, jvppRequest.isAdd);
- assertEquals(ByteDataTranslator.INSTANCE.booleanToByte(isIpv6), jvppRequest.isIpv6);
- assertEquals(FIB_TABLE_ID, jvppRequest.tableId);
- Assert.assertArrayEquals(FIB_TABLE_NAME.getBytes(), jvppRequest.name);
- }
-}