Search in sources :

Example 6 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project seldon-core by SeldonIO.

the class PredictorBean method predictorStateFromPredictorSpec.

// TODO
public PredictorState predictorStateFromPredictorSpec(PredictorSpec predictorSpec) {
    // Boolean enabled = PredictorSpec.getEnabled();
    Boolean enabled = true;
    PredictiveUnit rootUnit = predictorSpec.getGraph();
    Map<String, Container> containersMap = new HashMap<String, Container>();
    for (Container container : predictorSpec.getComponentSpec().getSpec().getContainersList()) {
        containersMap.put(container.getName(), container);
    }
    PredictiveUnitState rootState = new PredictiveUnitState(rootUnit, containersMap);
    return new PredictorState(rootUnit.getName(), rootState, enabled);
}
Also used : Container(io.kubernetes.client.proto.V1.Container) HashMap(java.util.HashMap) PredictiveUnit(io.seldon.protos.DeploymentProtos.PredictiveUnit)

Example 7 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project pravega by pravega.

the class BookkeeperService method createBookieApp.

private App createBookieApp() {
    App app = new App();
    app.setId(this.id);
    app.setCpus(cpu);
    app.setMem(mem);
    app.setInstances(instances);
    app.setConstraints(setConstraint("hostname", "UNIQUE"));
    app.setContainer(new Container());
    app.getContainer().setType(CONTAINER_TYPE);
    app.getContainer().setDocker(new Docker());
    app.getContainer().getDocker().setImage(IMAGE_PATH + "/nautilus/bookkeeper:" + PRAVEGA_VERSION);
    Collection<Volume> volumeCollection = new ArrayList<>();
    volumeCollection.add(createVolume("/bk", "mnt", "RW"));
    // TODO: add persistent volume  (see issue https://github.com/pravega/pravega/issues/639)
    app.getContainer().setVolumes(volumeCollection);
    app.setPorts(Arrays.asList(BK_PORT));
    app.setRequirePorts(true);
    // set env
    String zk = zkUri.getHost() + ":" + ZKSERVICE_ZKPORT;
    Map<String, Object> map = new HashMap<>();
    map.put("ZK_URL", zk);
    map.put("ZK", zk);
    map.put("bookiePort", String.valueOf(BK_PORT));
    map.put("DLOG_EXTRA_OPTS", "-Xms512m");
    app.setEnv(map);
    // healthchecks
    List<HealthCheck> healthCheckList = new ArrayList<>();
    healthCheckList.add(setHealthCheck(300, "TCP", false, 60, 20, 0, BK_PORT));
    app.setHealthChecks(healthCheckList);
    return app;
}
Also used : App(mesosphere.marathon.client.model.v2.App) Container(mesosphere.marathon.client.model.v2.Container) Docker(mesosphere.marathon.client.model.v2.Docker) Volume(mesosphere.marathon.client.model.v2.Volume) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HealthCheck(mesosphere.marathon.client.model.v2.HealthCheck)

Example 8 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project pravega by pravega.

the class ZookeeperService method createZookeeperApp.

private App createZookeeperApp() {
    App app = new App();
    app.setId(this.id);
    app.setCpus(cpu);
    app.setMem(mem);
    app.setInstances(instances);
    app.setContainer(new Container());
    app.getContainer().setType(CONTAINER_TYPE);
    app.getContainer().setDocker(new Docker());
    app.getContainer().getDocker().setImage(ZK_IMAGE);
    List<HealthCheck> healthCheckList = new ArrayList<>();
    final HealthCheck hc = setHealthCheck(300, "TCP", false, 60, 20, 0, ZKSERVICE_ZKPORT);
    healthCheckList.add(hc);
    app.setHealthChecks(healthCheckList);
    return app;
}
Also used : App(mesosphere.marathon.client.model.v2.App) Container(mesosphere.marathon.client.model.v2.Container) Docker(mesosphere.marathon.client.model.v2.Docker) HealthCheck(mesosphere.marathon.client.model.v2.HealthCheck) ArrayList(java.util.ArrayList)

Example 9 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testLspaObject.

@Test
public void testLspaObject() throws IOException, PCEPDeserializerException {
    final Stateful07LspaObjectParser parser = new Stateful07LspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
    final LspaBuilder builder = new LspaBuilder();
    final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject3RandVals.bin"));
    final SymbolicPathName tlv = new SymbolicPathNameBuilder().setPathName(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SymbolicPathName(new byte[] { (byte) 0x4d, (byte) 0x65, (byte) 0x64, (byte) 0x20, (byte) 0x74, (byte) 0x65, (byte) 0x73, (byte) 0x74, (byte) 0x20, (byte) 0x6f, (byte) 0x66, (byte) 0x20, (byte) 0x73, (byte) 0x79, (byte) 0x6d, (byte) 0x62, (byte) 0x6f, (byte) 0x6c, (byte) 0x69, (byte) 0x63, (byte) 0x20, (byte) 0x6e, (byte) 0x61, (byte) 0x6d, (byte) 0x65 })).build();
    builder.setIgnore(false);
    builder.setProcessingRule(false);
    builder.setExcludeAny(new AttributeFilter(0x20A1FEE3L));
    builder.setIncludeAny(new AttributeFilter(0x1A025CC7L));
    builder.setIncludeAll(new AttributeFilter(0x2BB66532L));
    builder.setHoldPriority((short) 0x02);
    builder.setSetupPriority((short) 0x03);
    builder.setLocalProtectionDesired(true);
    builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.lspa.TlvsBuilder().addAugmentation(Tlvs2.class, new Tlvs2Builder().setSymbolicPathName(tlv).build()).build());
    // Tlvs container does not contain toString
    final Object o = parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4));
    assertEquals(tlv, ((Lspa) o).getTlvs().getAugmentation(Tlvs2.class).getSymbolicPathName());
    // assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), ByteArray.cutBytes(result,
    // 4)));
    final ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
Also used : LspaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.LspaBuilder) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) SymbolicPathNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathNameBuilder) Tlvs2Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs2Builder) ByteBuf(io.netty.buffer.ByteBuf) Stateful07LspaObjectParser(org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07LspaObjectParser) AttributeFilter(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AttributeFilter) SymbolicPathName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathName) Test(org.junit.Test)

Example 10 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project netvirt by opendaylight.

the class VpnSubnetRouteHandler method onSubnetAddedToVpn.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void onSubnetAddedToVpn(Subnetmap subnetmap, boolean isBgpVpn, Long elanTag) {
    Uuid subnetId = subnetmap.getId();
    String subnetIp = subnetmap.getSubnetIp();
    SubnetOpDataEntry subOpEntry = null;
    SubnetOpDataEntryBuilder subOpBuilder = null;
    InstanceIdentifier<SubnetOpDataEntry> subOpIdentifier = null;
    Optional<SubnetOpDataEntry> optionalSubs = null;
    Uint32 label;
    requireNonNull(subnetId, LOGGING_PREFIX + " onSubnetAddedToVpn: SubnetId cannot be null or empty!");
    requireNonNull(subnetIp, LOGGING_PREFIX + " onSubnetAddedToVpn: SubnetPrefix cannot be null or empty!");
    requireNonNull(elanTag, LOGGING_PREFIX + " onSubnetAddedToVpn: ElanTag cannot be null or empty!");
    if (subnetmap.getVpnId() == null) {
        LOG.error("onSubnetAddedToVpn: VpnId {} for subnet {} not found, bailing out", subnetmap.getVpnId(), subnetId);
        return;
    }
    String vpnName = subnetmap.getVpnId().getValue();
    Uint32 vpnId = waitAndGetVpnIdIfInvalid(vpnName);
    if (VpnConstants.INVALID_ID.equals(vpnId)) {
        LOG.error("{} onSubnetAddedToVpn: VpnInstance to VPNId mapping not yet available for VpnName {} " + "processing subnet {} with IP {}, bailing out now.", LOGGING_PREFIX, vpnName, subnetId, subnetIp);
        return;
    }
    String primaryRd = vpnUtil.getPrimaryRd(vpnName);
    VpnInstanceOpDataEntry vpnInstanceOpData = waitAndGetVpnInstanceOpDataIfNull(vpnName, primaryRd);
    if (vpnInstanceOpData == null) {
        LOG.error("{} onSubnetAddedToVpn: VpnInstanceOpData not yet available for VpnName {} " + "processing subnet {} with IP {}, bailing out now.", LOGGING_PREFIX, vpnName, subnetId, subnetIp);
        return;
    }
    LOG.info("{} onSubnetAddedToVpn: Subnet {} with IP {} being added to vpn {}", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName);
    // TODO(vivek): Change this to use more granularized lock at subnetId level
    try {
        vpnUtil.lockSubnet(subnetId.getValue());
        if (isBgpVpn) {
            InstanceIdentifier<Networks> netsIdentifier = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(subnetmap.getNetworkId())).build();
            Optional<Networks> optionalNets = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier);
            if (optionalNets.isPresent()) {
                LOG.info("{} onSubnetAddedToVpn: subnet {} with IP {} is an external subnet on external " + "network {}, so ignoring this for SubnetRoute on vpn {}", LOGGING_PREFIX, subnetId.getValue(), subnetIp, subnetmap.getNetworkId().getValue(), vpnName);
                return;
            }
        }
        // Create and add SubnetOpDataEntry object for this subnet to the SubnetOpData container
        subOpIdentifier = InstanceIdentifier.builder(SubnetOpData.class).child(SubnetOpDataEntry.class, new SubnetOpDataEntryKey(subnetId)).build();
        optionalSubs = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, subOpIdentifier);
        if (optionalSubs.isPresent()) {
            LOG.error("{} onSubnetAddedToVpn: SubnetOpDataEntry for subnet {} with ip {} and vpn {} already" + " detected to be present", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName);
            return;
        }
        LOG.debug("{} onSubnetAddedToVpn: Creating new SubnetOpDataEntry node for subnet {} subnetIp {} " + "vpn {}", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName);
        subOpBuilder = new SubnetOpDataEntryBuilder().withKey(new SubnetOpDataEntryKey(subnetId));
        subOpBuilder.setSubnetId(subnetId);
        subOpBuilder.setSubnetCidr(subnetIp);
        if (isBgpVpn && !VpnUtil.isBgpVpn(vpnName, primaryRd)) {
            LOG.error("{} onSubnetAddedToVpn: The VPN Instance name {} does not have RD. Bailing out for" + " subnet {} subnetIp {} ", LOGGING_PREFIX, vpnName, subnetId.getValue(), subnetIp);
            return;
        }
        // Allocate MPLS label for subnet-route at the time SubnetOpDataEntry creation
        label = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME, VpnUtil.getNextHopLabelKey(primaryRd, subnetIp));
        if (label == VpnConstants.INVALID_ID) {
            LOG.error("onSubnetAddedToVpn: Unable to retrieve label for rd {}, subnetIp {}", primaryRd, subnetIp);
            return;
        }
        subOpBuilder.setVrfId(primaryRd);
        subOpBuilder.setVpnName(vpnName);
        subOpBuilder.setSubnetToDpn(new ArrayList<>());
        subOpBuilder.setRouteAdvState(TaskState.Idle);
        subOpBuilder.setElanTag(elanTag);
        subOpBuilder.setLabel(label);
        Long l3Vni = vpnInstanceOpData.getL3vni() != null ? vpnInstanceOpData.getL3vni().toJava() : 0L;
        subOpBuilder.setL3vni(l3Vni);
        subOpEntry = subOpBuilder.build();
        SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, subOpIdentifier, subOpEntry, VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY);
        LOG.info("{} onSubnetAddedToVpn: Added subnetopdataentry to OP Datastore for subnet {}", LOGGING_PREFIX, subnetId.getValue());
    } catch (TransactionCommitFailedException e) {
        LOG.error("{} Creation of SubnetOpDataEntry for subnet {} failed ", LOGGING_PREFIX, subnetId.getValue(), e);
        // The second part of this method depends on subnetmap being non-null so fail fast here.
        return;
    } catch (RuntimeException e) {
        // TODO: Avoid this
        LOG.error("{} onSubnetAddedToVpn: Unable to handle subnet {} with ip {} added to vpn {}", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName, e);
        return;
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("{} onSubnetAddedToVpn: Failed to read data store for subnet {} ip {} vpn {}", LOGGING_PREFIX, subnetId, subnetIp, vpnName);
        return;
    } finally {
        vpnUtil.unlockSubnet(subnetId.getValue());
    }
    try {
        // In second critical section , Port-Op-Data will be updated.
        vpnUtil.lockSubnet(subnetId.getValue());
        Uint64 dpnId = null;
        SubnetToDpn subDpn = null;
        Map<Uint64, SubnetToDpn> subDpnMap = new HashMap<>();
        optionalSubs = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, subOpIdentifier);
        subOpBuilder = new SubnetOpDataEntryBuilder(optionalSubs.get()).withKey(new SubnetOpDataEntryKey(subnetId));
        List<Uuid> portList = subnetmap.getPortList();
        if (portList != null) {
            for (Uuid port : portList) {
                Interface intfState = InterfaceUtils.getInterfaceStateFromOperDS(dataBroker, port.getValue());
                if (intfState != null) {
                    try {
                        dpnId = InterfaceUtils.getDpIdFromInterface(intfState);
                    } catch (Exception e) {
                        LOG.error("{} onSubnetAddedToVpn: Unable to obtain dpnId for interface {}," + " subnetroute inclusion for this interface for subnet {} subnetIp {} " + "vpn {} failed with exception", LOGGING_PREFIX, port.getValue(), subnetId.getValue(), subnetIp, vpnName, e);
                        continue;
                    }
                    if (dpnId.equals(Uint64.ZERO)) {
                        LOG.error("{} onSubnetAddedToVpn: Port {} is not assigned DPN yet," + " ignoring subnet {} subnetIP {} vpn {}", LOGGING_PREFIX, port.getValue(), subnetId.getValue(), subnetIp, vpnName);
                        continue;
                    }
                    subOpDpnManager.addPortOpDataEntry(port.getValue(), subnetId, dpnId);
                    if (intfState.getOperStatus() != OperStatus.Up) {
                        LOG.error("{} onSubnetAddedToVpn: Port {} is not UP yet, ignoring subnet {}" + " subnetIp {} vpn {}", LOGGING_PREFIX, port.getValue(), subnetId.getValue(), subnetIp, vpnName);
                        continue;
                    }
                    subDpn = subOpDpnManager.addInterfaceToDpn(subnetId, dpnId, port.getValue());
                    if (intfState.getOperStatus() == OperStatus.Up) {
                        // port is UP
                        subDpnMap.put(dpnId, subDpn);
                    }
                } else {
                    subOpDpnManager.addPortOpDataEntry(port.getValue(), subnetId, null);
                }
            }
            if (subDpnMap.size() > 0) {
                subOpBuilder.setSubnetToDpn(new ArrayList<>(subDpnMap.values()));
            }
        }
        electNewDpnForSubnetRoute(subOpBuilder, null, /* oldDpnId */
        subnetId, subnetmap.getNetworkId(), isBgpVpn, label);
        subOpEntry = subOpBuilder.build();
        SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.OPERATIONAL, subOpIdentifier, subOpEntry, VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY);
        LOG.info("{} onSubnetAddedToVpn: Added PortOpDataEntry and VpnInterfaces to SubnetOpData" + " for subnet {} subnetIp {} vpn {} TaskState {} lastTaskState {}", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName, subOpEntry.getRouteAdvState(), subOpEntry.getLastAdvState());
    } catch (RuntimeException e) {
        LOG.error("{} onSubnetAddedToVpn: Unable to handle subnet {} with ip {} added to vpn {}", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName, e);
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("{} onSubnetAddedToVpn: Failed to read data store for subnet {} ip {} vpn {}", LOGGING_PREFIX, subnetId, subnetIp, vpnName);
    } catch (TransactionCommitFailedException ex) {
        LOG.error("{} onSubnetAddedToVpn: Creation of SubnetOpDataEntry for subnet {} subnetIp {} vpn {} failed", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName, ex);
    } finally {
        vpnUtil.unlockSubnet(subnetId.getValue());
    }
}
Also used : Networks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks) ExternalNetworks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks) HashMap(java.util.HashMap) SubnetOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntry) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) Uint32(org.opendaylight.yangtools.yang.common.Uint32) SubnetOpDataEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntryBuilder) SubnetOpData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.SubnetOpData) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) SubnetToDpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpn) NetworksKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksKey) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) SubnetOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntryKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Aggregations

ItemStack (org.bukkit.inventory.ItemStack)45 Test (org.junit.Test)16 HashMap (java.util.HashMap)10 Container (net.minecraft.server.v1_12_R1.Container)9 Container (net.minecraft.server.v1_16_R3.Container)9 Container (org.flyte.api.v1.Container)9 FailedNbt (com.ruinscraft.panilla.api.exception.FailedNbt)8 INbtTagCompound (com.ruinscraft.panilla.api.nbt.INbtTagCompound)8 Container (net.minecraft.server.v1_11_R1.Container)8 Container (net.minecraft.server.v1_14_R1.Container)8 Container (net.minecraft.server.v1_15_R1.Container)8 Container (net.minecraft.server.v1_16_R1.Container)8 Container (net.minecraft.server.v1_16_R2.Container)8 Container (net.minecraft.server.v1_8_R3.Container)8 ByteBuf (io.netty.buffer.ByteBuf)7 ArrayList (java.util.ArrayList)7 Container (net.minecraft.server.v1_13_R1.Container)7 Container (net.minecraft.server.v1_13_R2.Container)6 Container (net.minecraft.server.v1_10_R1.Container)5 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)5