From aa3fb2c1271c948f9a3c5a4ab22ce146be13163e Mon Sep 17 00:00:00 2001 From: Jan Srnicek Date: Wed, 31 Aug 2016 07:46:41 +0200 Subject: HONEYCOMB-75 - Lisp implemetation Rebased on final minimal distro Change-Id: Ib71fc59e62dda4633f4f79c5c7417a4aaf02a177 Signed-off-by: Jan Srnicek Signed-off-by: Florin Coras Signed-off-by: Maros Marsalek --- .../read/dump/check/LocatorDumpCheck.java | 37 ++++ .../read/dump/check/LocatorSetsDumpCheck.java | 38 ++++ .../read/dump/check/MapResolverDumpCheck.java | 37 ++++ .../read/dump/check/MappingsDumpCheck.java | 40 +++++ .../read/dump/check/VniTableDumpCheck.java | 37 ++++ .../read/dump/executor/AbstractDumpExecutor.java | 35 ++++ .../read/dump/executor/LocatorDumpExecutor.java | 64 +++++++ .../dump/executor/LocatorSetsDumpExecutor.java | 55 ++++++ .../dump/executor/MapResolversDumpExecutor.java | 51 ++++++ .../read/dump/executor/MappingsDumpExecutor.java | 70 ++++++++ .../read/dump/executor/VniTableDumpExecutor.java | 50 ++++++ .../dump/executor/params/LocatorDumpParams.java | 82 +++++++++ .../dump/executor/params/MappingsDumpParams.java | 192 +++++++++++++++++++++ 13 files changed, 788 insertions(+) create mode 100644 lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorDumpCheck.java create mode 100755 lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorSetsDumpCheck.java create mode 100755 lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MapResolverDumpCheck.java create mode 100755 lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MappingsDumpCheck.java create mode 100755 lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/VniTableDumpCheck.java create mode 100644 lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/AbstractDumpExecutor.java create mode 100644 lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java create mode 100755 lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java create mode 100755 lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java create mode 100755 lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java create mode 100755 lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java create mode 100644 lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/LocatorDumpParams.java create mode 100755 lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/MappingsDumpParams.java (limited to 'lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump') diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorDumpCheck.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorDumpCheck.java new file mode 100644 index 000000000..530be98ed --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorDumpCheck.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2016 Cisco 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.honeycomb.lisp.translate.read.dump.check; + +import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpNonEmptyCheck; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.DumpCheckFailedException; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.i.DumpEmptyException; +import org.openvpp.jvpp.core.dto.LispLocatorDetailsReplyDump; + +public class LocatorDumpCheck implements EntityDumpNonEmptyCheck { + + @Override + public void assertNotEmpty(final LispLocatorDetailsReplyDump data) throws DumpCheckFailedException { + + if (data == null) { + throw new DumpEmptyException("Locator dump is null"); + } + + if (data.lispLocatorDetails == null) { + throw new DumpEmptyException("Locator dump is empty"); + } + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorSetsDumpCheck.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorSetsDumpCheck.java new file mode 100755 index 000000000..eac757d50 --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorSetsDumpCheck.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016 Cisco 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.honeycomb.lisp.translate.read.dump.check; + + +import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpNonEmptyCheck; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.DumpCheckFailedException; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.i.DumpEmptyException; +import org.openvpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump; + +public class LocatorSetsDumpCheck implements EntityDumpNonEmptyCheck { + + @Override + public void assertNotEmpty(final LispLocatorSetDetailsReplyDump data) throws DumpCheckFailedException { + + if (data == null) { + throw new DumpEmptyException("Locator sets dump is null"); + } + + if (data.lispLocatorSetDetails == null) { + throw new DumpEmptyException("Locator sets dump is empty"); + } + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MapResolverDumpCheck.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MapResolverDumpCheck.java new file mode 100755 index 000000000..e018702ee --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MapResolverDumpCheck.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2016 Cisco 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.honeycomb.lisp.translate.read.dump.check; + + +import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpNonEmptyCheck; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.DumpCheckFailedException; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.i.DumpEmptyException; +import org.openvpp.jvpp.core.dto.LispMapResolverDetailsReplyDump; + +public class MapResolverDumpCheck implements EntityDumpNonEmptyCheck { + + @Override + public void assertNotEmpty(final LispMapResolverDetailsReplyDump data) throws DumpCheckFailedException { + if (data == null) { + throw new DumpEmptyException("Map resolvers dump is null"); + } + + if (data.lispMapResolverDetails == null) { + throw new DumpEmptyException("Map resolvers dump is empty"); + } + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MappingsDumpCheck.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MappingsDumpCheck.java new file mode 100755 index 000000000..f34ea1b8e --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MappingsDumpCheck.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2016 Cisco 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.honeycomb.lisp.translate.read.dump.check; + + +import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpNonEmptyCheck; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.DumpCheckFailedException; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.i.DumpEmptyException; +import org.openvpp.jvpp.core.dto.LispEidTableDetailsReplyDump; + +/** + * Common dump check for both local and remote mappings + */ +public class MappingsDumpCheck implements EntityDumpNonEmptyCheck { + + @Override + public void assertNotEmpty(final LispEidTableDetailsReplyDump data) throws DumpCheckFailedException { + if (data == null) { + throw new DumpEmptyException("Mappings dump is null"); + } + + if (data.lispEidTableDetails == null) { + throw new DumpEmptyException("Mappings dump is empty"); + } + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/VniTableDumpCheck.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/VniTableDumpCheck.java new file mode 100755 index 000000000..942d974e6 --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/VniTableDumpCheck.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2016 Cisco 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.honeycomb.lisp.translate.read.dump.check; + + +import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpNonEmptyCheck; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.DumpCheckFailedException; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.i.DumpEmptyException; +import org.openvpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump; + +public class VniTableDumpCheck implements EntityDumpNonEmptyCheck { + + @Override + public void assertNotEmpty(final LispEidTableMapDetailsReplyDump data) throws DumpCheckFailedException { + if (data == null) { + throw new DumpEmptyException("Vni table dump is null"); + } + + if (data.lispEidTableMapDetails == null) { + throw new DumpEmptyException("Bni table dump is empty"); + } + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/AbstractDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/AbstractDumpExecutor.java new file mode 100644 index 000000000..fbd2003e8 --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/AbstractDumpExecutor.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2016 Cisco 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.honeycomb.lisp.translate.read.dump.executor; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.annotation.Nonnull; +import org.openvpp.jvpp.core.future.FutureJVppCore; + + +/** + * Abstract holder for jvpp refference + */ +public abstract class AbstractDumpExecutor { + + protected final FutureJVppCore vppApi; + + protected AbstractDumpExecutor(@Nonnull final FutureJVppCore vppApi) { + this.vppApi = checkNotNull(vppApi, "VPP Api refference cannot be null"); + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java new file mode 100644 index 000000000..16e6deaab --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2016 Cisco 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.honeycomb.lisp.translate.read.dump.executor; + +import static com.google.common.base.Preconditions.checkNotNull; + +import io.fd.honeycomb.lisp.translate.read.dump.executor.params.LocatorDumpParams; +import io.fd.honeycomb.translate.v3po.util.TranslateUtils; +import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpExecutor; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpCallFailedException; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpTimeoutException; +import java.util.concurrent.TimeoutException; +import javax.annotation.Nonnull; +import org.openvpp.jvpp.VppBaseCallException; +import org.openvpp.jvpp.core.dto.LispLocatorDetailsReplyDump; +import org.openvpp.jvpp.core.dto.LispLocatorDump; +import org.openvpp.jvpp.core.future.FutureJVppCore; + + +/** + * Executor for dumping of locators + */ +public class LocatorDumpExecutor extends AbstractDumpExecutor + implements EntityDumpExecutor { + + + public LocatorDumpExecutor(@Nonnull final FutureJVppCore vppApi) { + super(vppApi); + } + + @Override + public LispLocatorDetailsReplyDump executeDump(final LocatorDumpParams params) throws DumpExecutionFailedException { + checkNotNull(params, "Params for dump request not present"); + + LispLocatorDump request = new LispLocatorDump(); + request.locatorSetIndex = params.getLocatorSetIndex(); + request.filter = params.getFilter(); + + try { + return TranslateUtils.getReply(vppApi.lispLocatorDump(request).toCompletableFuture()); + } catch (TimeoutException e) { + throw DumpTimeoutException + .wrapTimeoutException("Locator dump ended in timeout with params" + params.toString(), e); + } catch (VppBaseCallException e) { + throw DumpCallFailedException + .wrapFailedCallException("Locator dump failed with params" + params.toString(), e); + } + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java new file mode 100755 index 000000000..d074bae52 --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016 Cisco 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.honeycomb.lisp.translate.read.dump.executor; + + +import io.fd.honeycomb.translate.v3po.util.TranslateUtils; +import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpExecutor; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpCallFailedException; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpTimeoutException; +import java.util.concurrent.TimeoutException; +import javax.annotation.Nonnull; +import org.openvpp.jvpp.VppBaseCallException; +import org.openvpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump; +import org.openvpp.jvpp.core.dto.LispLocatorSetDump; +import org.openvpp.jvpp.core.future.FutureJVppCore; + + +public class LocatorSetsDumpExecutor extends AbstractDumpExecutor + implements EntityDumpExecutor { + + public LocatorSetsDumpExecutor(@Nonnull FutureJVppCore api) { + super(api); + } + + @Override + public LispLocatorSetDetailsReplyDump executeDump(final Void params) throws DumpExecutionFailedException { + + LispLocatorSetDump request = new LispLocatorSetDump(); + request.filter = 0; + + try { + return TranslateUtils + .getReply(vppApi.lispLocatorSetDump(request).toCompletableFuture()); + } catch (TimeoutException e) { + throw DumpTimeoutException.wrapTimeoutException("Locator sets dump ended in timeout", e); + } catch (VppBaseCallException e) { + throw DumpCallFailedException.wrapFailedCallException("Locator sets dump failed", e); + } + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java new file mode 100755 index 000000000..ec1cabd54 --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2016 Cisco 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.honeycomb.lisp.translate.read.dump.executor; + + +import io.fd.honeycomb.translate.v3po.util.TranslateUtils; +import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpExecutor; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpCallFailedException; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpTimeoutException; +import java.util.concurrent.TimeoutException; +import javax.annotation.Nonnull; +import org.openvpp.jvpp.VppBaseCallException; +import org.openvpp.jvpp.core.dto.LispMapResolverDetailsReplyDump; +import org.openvpp.jvpp.core.dto.LispMapResolverDump; +import org.openvpp.jvpp.core.future.FutureJVppCore; + + +public class MapResolversDumpExecutor extends AbstractDumpExecutor + implements EntityDumpExecutor { + + public MapResolversDumpExecutor(@Nonnull FutureJVppCore api) { + super(api); + } + + @Override + public LispMapResolverDetailsReplyDump executeDump(final Void params) throws DumpExecutionFailedException { + try { + return TranslateUtils.getReply(vppApi.lispMapResolverDump(new LispMapResolverDump()).toCompletableFuture()); + } catch (TimeoutException e) { + throw DumpTimeoutException + .wrapTimeoutException("Map resolver dump execution ended in timeout", e); + } catch (VppBaseCallException e) { + throw DumpCallFailedException.wrapFailedCallException("Map resolver dump execution failed", e); + } + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java new file mode 100755 index 000000000..d43713967 --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2016 Cisco 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.honeycomb.lisp.translate.read.dump.executor; + + +import static com.google.common.base.Preconditions.checkNotNull; + +import io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams; +import io.fd.honeycomb.translate.v3po.util.TranslateUtils; +import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpExecutor; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpCallFailedException; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpTimeoutException; +import java.util.concurrent.TimeoutException; +import javax.annotation.Nonnull; +import org.openvpp.jvpp.VppBaseCallException; +import org.openvpp.jvpp.core.dto.LispEidTableDetailsReplyDump; +import org.openvpp.jvpp.core.dto.LispEidTableDump; +import org.openvpp.jvpp.core.future.FutureJVppCore; + + +/** + * Common dump executor for both local and remote mappings + */ +public class MappingsDumpExecutor extends AbstractDumpExecutor + implements EntityDumpExecutor { + + public MappingsDumpExecutor(@Nonnull FutureJVppCore vppApi) { + super(vppApi); + } + + + @Override + public LispEidTableDetailsReplyDump executeDump(final MappingsDumpParams params) + throws DumpExecutionFailedException { + checkNotNull(params, "Params for dump request not present"); + + LispEidTableDump request = new LispEidTableDump(); + request.eid = params.getEid(); + request.eidSet = params.getEidSet(); + request.eidType = params.getEidType(); + request.prefixLength = params.getPrefixLength(); + request.vni = params.getVni(); + request.filter = params.getFilter(); + + try { + return TranslateUtils.getReply(vppApi.lispEidTableDump(request).toCompletableFuture()); + } catch (TimeoutException e) { + throw DumpTimeoutException + .wrapTimeoutException("Mappings dump execution timed out with params " + params.toString(), e); + } catch (VppBaseCallException e) { + throw DumpCallFailedException + .wrapFailedCallException("Mappings dump execution failed with params " + params.toString(), e); + } + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java new file mode 100755 index 000000000..cb5f06393 --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2016 Cisco 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.honeycomb.lisp.translate.read.dump.executor; + + +import io.fd.honeycomb.translate.v3po.util.TranslateUtils; +import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpExecutor; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpCallFailedException; +import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpTimeoutException; +import java.util.concurrent.TimeoutException; +import javax.annotation.Nonnull; +import org.openvpp.jvpp.VppBaseCallException; +import org.openvpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump; +import org.openvpp.jvpp.core.dto.LispEidTableMapDump; +import org.openvpp.jvpp.core.future.FutureJVppCore; + + +public class VniTableDumpExecutor extends AbstractDumpExecutor + implements EntityDumpExecutor { + + public VniTableDumpExecutor(@Nonnull FutureJVppCore api) { + super(api); + } + + @Override + public LispEidTableMapDetailsReplyDump executeDump(Void params) throws DumpExecutionFailedException { + try { + return TranslateUtils.getReply(vppApi.lispEidTableMapDump(new LispEidTableMapDump()).toCompletableFuture()); + } catch (TimeoutException e) { + throw DumpTimeoutException.wrapTimeoutException("Eid table map dump ended in timeout", e); + } catch (VppBaseCallException e) { + throw DumpCallFailedException.wrapFailedCallException("Eid table map dump failed", e); + } + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/LocatorDumpParams.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/LocatorDumpParams.java new file mode 100644 index 000000000..eda1e9771 --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/LocatorDumpParams.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016 Cisco 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.honeycomb.lisp.translate.read.dump.executor.params; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Params for dumping locators + */ +public final class LocatorDumpParams { + + private final int locatorSetIndex; + private final byte filter; + + private LocatorDumpParams(LocatorDumpParamsBuilder builder) { + this.locatorSetIndex = builder.locatorSetIndex; + this.filter = builder.filter; + } + + public int getLocatorSetIndex() { + return locatorSetIndex; + } + + public byte getFilter() { + return filter; + } + + /** + * Enum for filtering which locators to dump + */ + public enum LocatorDumpFilter { + + ALL(0), + LOCAL(1), + REMOTE(2); + + private final int value; + + private LocatorDumpFilter(int value) { + this.value = value; + } + + public final int getValue() { + return value; + } + } + + public static final class LocatorDumpParamsBuilder { + + public int locatorSetIndex; + public byte filter; + + + public LocatorDumpParamsBuilder setLocatorSetIndex(final int locatorSetIndex) { + this.locatorSetIndex = locatorSetIndex; + return this; + } + + public LocatorDumpParamsBuilder setFilter(final LocatorDumpFilter filter) { + this.filter = Integer.valueOf(checkNotNull(filter, "Cannot set null filter").getValue()).byteValue(); + return this; + } + + public LocatorDumpParams build() { + return new LocatorDumpParams(this); + } + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/MappingsDumpParams.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/MappingsDumpParams.java new file mode 100755 index 000000000..1f7990c9b --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/MappingsDumpParams.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2016 Cisco 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.honeycomb.lisp.translate.read.dump.executor.params; + +import io.fd.honeycomb.lisp.translate.read.dump.executor.MappingsDumpExecutor; +import java.util.Arrays; + +/** + * Parameters for executing {@link MappingsDumpExecutor} + */ +public final class MappingsDumpParams { + + private final byte eidSet; + private final byte prefixLength; + private final int vni; + private final byte eidType; + private final byte[] eid; + private final byte filter; + + private MappingsDumpParams(MappingsDumpParamsBuilder builder) { + this.eidSet = builder.eidSet; + this.prefixLength = builder.prefixLength; + this.vni = builder.vni; + this.eidType = builder.eidType; + this.eid = builder.eid; + this.filter = builder.filter; + } + + + public byte getEidSet() { + return eidSet; + } + + public byte getPrefixLength() { + return prefixLength; + } + + public int getVni() { + return vni; + } + + public byte getEidType() { + return eidType; + } + + public byte[] getEid() { + return eid; + } + + public final byte getFilter() { + return filter; + } + + @Override + public String toString() { + return "MappingsDumpParams{" + + "eidSet=" + eidSet + + ", prefixLength=" + prefixLength + + ", vni=" + vni + + ", eidType=" + eidType + + ", eid=" + Arrays.toString(eid) + + ", filter=" + filter + + '}'; + } + + /** + * Type of requested mapping eid + */ + public enum EidType { + IPV4(0), + IPV6(1), + MAC(2); + + private final int value; + + private EidType(final int value) { + this.value = value; + } + + public static final EidType valueOf(int value) { + switch (value) { + case 0: + return IPV4; + case 1: + return IPV6; + case 2: + return MAC; + default: + throw new IllegalArgumentException("Illegal value"); + } + } + + public final int getValue() { + return this.value; + } + } + + /** + * Type of requested mapping + */ + public enum FilterType { + ALL(0), + LOCAL(1), + REMOTE(2); + + private final int value; + + private FilterType(final int value) { + this.value = value; + } + + public final int getValue() { + return this.value; + } + } + + public enum QuantityType { + ALL(0), + SPECIFIC(1); + + private final int value; + + private QuantityType(final int value) { + this.value = value; + } + + public final int getValue() { + return this.value; + } + } + + public static final class MappingsDumpParamsBuilder { + private byte eidSet; + private byte prefixLength; + private int vni; + private byte eidType; + private byte[] eid; + private byte filter; + + public static final MappingsDumpParamsBuilder newInstance() { + return new MappingsDumpParamsBuilder(); + } + + public MappingsDumpParamsBuilder setEidSet(final QuantityType quantityType) { + this.eidSet = (byte) quantityType.getValue(); + return this; + } + + public MappingsDumpParamsBuilder setPrefixLength(final byte prefixLength) { + this.prefixLength = prefixLength; + return this; + } + + public MappingsDumpParamsBuilder setVni(final int vni) { + this.vni = vni; + return this; + } + + public MappingsDumpParamsBuilder setEidType(final EidType eidType) { + this.eidType = (byte) eidType.getValue(); + return this; + } + + public MappingsDumpParamsBuilder setEid(final byte[] eid) { + this.eid = eid; + return this; + } + + public MappingsDumpParamsBuilder setFilter(final FilterType filterType) { + this.filter = (byte) filterType.getValue(); + return this; + } + + public MappingsDumpParams build() { + return new MappingsDumpParams(this); + } + } +} -- cgit 1.2.3-korg