当前位置: 首页>>代码示例>>Java>>正文


Java Element类代码示例

本文整理汇总了Java中org.osc.sdk.controller.element.Element的典型用法代码示例。如果您正苦于以下问题:Java Element类的具体用法?Java Element怎么用?Java Element使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Element类属于org.osc.sdk.controller.element包,在下文中一共展示了Element类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerInspectionPort

import org.osc.sdk.controller.element.Element; //导入依赖的package包/类
@Override
public Element registerInspectionPort(InspectionPortElement inspectionPort) throws Exception {
    if (inspectionPort == null) {
        throw new IllegalArgumentException("Attempt to register null InspectionPort");
    }

    return this.txControl.required(() -> {

        // must be within this transaction, because if the DB retrievals inside makeInspectionPortEntry
        // are inside the required() call themselves. That makes them a part of a separate transaction

        InspectionPortEntity inspectionPortEntity = (InspectionPortEntity) getInspectionPort(inspectionPort);

        if (inspectionPortEntity == null) {
            inspectionPortEntity = this.utils.makeInspectionPortEntity(inspectionPort);
        }

        inspectionPortEntity = this.em.merge(inspectionPortEntity);

        return inspectionPortEntity;
    });
}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:23,代码来源:SampleSdnRedirectionApi.java

示例2: updateInspectionPort

import org.osc.sdk.controller.element.Element; //导入依赖的package包/类
public Element updateInspectionPort(InspectionPortEntity inspectionPort) throws Exception {

        InspectionPortEntity inspectionPortEntity = (InspectionPortEntity) getInspectionPort(inspectionPort);
        this.utils.throwExceptionIfNullElementAndId(inspectionPortEntity, "Inspection port");

        this.utils.throwExceptionIfNullElementAndId(inspectionPort.getIngressPort(), "Ingress port");
        this.utils.throwExceptionIfNullElementAndId(inspectionPort.getEgressPort(), "Egress port");

        this.utils.throwExceptionIfIdMismatch(inspectionPortEntity.getEgressPort().getElementId(),
                inspectionPort.getEgressPort().getElementId());
        this.utils.throwExceptionIfIdMismatch(inspectionPortEntity.getIngressPort().getElementId(),
                inspectionPort.getIngressPort().getElementId());

        return this.txControl.required(() -> {
            inspectionPortEntity.setEgressPort(inspectionPort.getEgressPort());
            inspectionPortEntity.setIngressPort(inspectionPort.getIngressPort());

            return this.em.merge(inspectionPortEntity);
        });
    }
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:21,代码来源:SampleSdnRedirectionApi.java

示例3: testApi_GetInspectionHooksIds_Succeeds

import org.osc.sdk.controller.element.Element; //导入依赖的package包/类
@Test
public void testApi_GetInspectionHooksIds_Succeeds() throws Exception {
    //Arrange
    this.redirApi = new SampleSdnRedirectionApi(this.txControl, this.em);

    InspectionPortEntity inspectionPortElement = new InspectionPortEntity(null, ingress, egress);

    Element registeredElement = this.redirApi.registerInspectionPort(inspectionPortElement);

    assertNotNull(registeredElement);
    assertNotNull(registeredElement.getElementId());

    //Act
    String hookId = this.redirApi.installInspectionHook(inspected, inspectionPortElement, 0L, VLAN, 0L, NA);

    //Assert
    assertNotNull(hookId);
    assertTrue(this.redirApi.getInspectionHooksIds().contains(hookId));
    assertEquals(1, this.redirApi.getInspectionHooksIds().size());
}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:21,代码来源:SampleSdnRedirectionApiTest.java

示例4: executeTransaction

import org.osc.sdk.controller.element.Element; //导入依赖的package包/类
@Override
public void executeTransaction(EntityManager em) throws Exception {
    OSCEntityManager<DistributedApplianceInstance> daiEmgr = new OSCEntityManager<DistributedApplianceInstance>(DistributedApplianceInstance.class, em, this.txBroadcastUtil);
    this.dai = daiEmgr.findByPrimaryKey(this.dai.getId());

    Element inspectionPortElement = null;

    try (SdnRedirectionApi redirection = this.apiFactoryService.createNetworkRedirectionApi(this.dai.getVirtualSystem())) {
        DefaultNetworkPort ingressPort = new DefaultNetworkPort(this.dai.getInspectionOsIngressPortId(),
                this.dai.getInspectionIngressMacAddress());
        DefaultNetworkPort egressPort = new DefaultNetworkPort(this.dai.getInspectionOsEgressPortId(),
                this.dai.getInspectionEgressMacAddress());

        DefaultInspectionPort inspectionPort = new DefaultInspectionPort(ingressPort, egressPort, this.dai.getInspectionElementId(), this.dai.getInspectionElementParentId());

        // This should create or update an existing inspection port
        // If the this.dai.getInspectionElementId() is null no ID is provided to the SDN controller which
        // means a new one should be created, else the targeted one should be updated with the provided network ports
        inspectionPortElement = redirection.registerInspectionPort(inspectionPort);
    }

    this.dai.setInspectionElementId(inspectionPortElement.getElementId());
    // After removing the inspection port from the SDN controller we can now delete this orphan DAI
    OSCEntityManager.update(em, this.dai, this.txBroadcastUtil);
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:26,代码来源:RegisterK8sDAIInspectionPortTask.java

示例5: throwExceptionIfNullElementAndId

import org.osc.sdk.controller.element.Element; //导入依赖的package包/类
public void throwExceptionIfNullElementAndId(Element element, String type) {
    if (element == null || element.getElementId() == null) {
        String msg = String.format("null passed for %s !", type);
        LOG.error(msg);
        throw new IllegalArgumentException(msg);
    }
}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:8,代码来源:RedirectionApiUtils.java

示例6: configure

import org.osc.sdk.controller.element.Element; //导入依赖的package包/类
@Override
protected Application configure() {
    baseTestConfiguration();

    //configure services
    this.context = new OsgiContext();

    SdnControllerApi sdnApi = Mockito.mock(SdnControllerApi.class);
    this.context.registerService(SdnControllerApi.class, sdnApi);

    SampleSdnRedirectionApi sdnRedirApi = Mockito.mock(SampleSdnRedirectionApi.class);
    this.context.registerService(SampleSdnRedirectionApi.class, sdnRedirApi);

    InspectionPortApis service = new InspectionPortApis();
    this.context.registerInjectActivateService(service);

    ResourceConfig application = getBaseResourceConfiguration().register(service);

    //configure responses
    this.expectedResponseList = new ArrayList<String>();
    this.expectedResponseList.add("InspPortId");

    Mockito.<SdnRedirectionApi> when(sdnApi.createRedirectionApi(any(), any()))
    .thenReturn(sdnRedirApi);

    try {
        Mockito.<List<String>> when(sdnRedirApi.getInspectionPortsIds()).thenReturn(this.expectedResponseList);
        Mockito.<InspectionPortElement> when(sdnRedirApi.getInspectionPort(any()))
                .thenReturn(createInspectionPortEntity());
        Mockito.<Element> when(sdnRedirApi.registerInspectionPort(any())).thenReturn(createInspectionPortEntity());
        Mockito.<Element> when(sdnRedirApi.updateInspectionPort(any())).thenReturn(createInspectionPortEntity());
        Mockito.doNothing().when(sdnRedirApi).removeInspectionPort(any());
        super.callRealMethods(sdnRedirApi);
    }
    catch (Exception ex) {
        Assert.fail(ex.getClass() + " : " + ex.getMessage());
    }

    return application;
}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:41,代码来源:InspectionPortApisTest.java

示例7: testUtils_RemoveInstalledInspectionHook_InspectionHookDisappears

import org.osc.sdk.controller.element.Element; //导入依赖的package包/类
@Test
public void testUtils_RemoveInstalledInspectionHook_InspectionHookDisappears() throws Exception {
    // Arrange.
    @SuppressWarnings("resource")
    SampleSdnRedirectionApi redirApi = new SampleSdnRedirectionApi(this.txControl, this.em);

    InspectionPortEntity inspectionPortElement = new InspectionPortEntity(null, ingress, egress);

    // expected before installInspectionHook
    Element registeredElement = redirApi.registerInspectionPort(inspectionPortElement);

    assertNotNull(registeredElement);
    assertNotNull(registeredElement.getElementId());

    final String hookId = redirApi.installInspectionHook(inspected, inspectionPortElement, 0L, VLAN, 0L,
            NA);

    InspectionHookEntity inspectionHookEntity = this.txControl.required(() -> {
        return this.em.find(InspectionHookEntity.class, hookId);
    });
    assertNotNull(inspectionHookEntity);

    // Act.
    this.utils.removeSingleInspectionHook(hookId);

    inspectionHookEntity = this.txControl.required(() -> {
        return this.em.find(InspectionHookEntity.class, hookId);
    });

    // Assert.
    assertEquals(null, inspectionHookEntity);
}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:33,代码来源:RedirectionApiUtilsTest.java

示例8: testApi_RemoveAllInspectionHooks_InspectionHookDisappears

import org.osc.sdk.controller.element.Element; //导入依赖的package包/类
@Test
public void testApi_RemoveAllInspectionHooks_InspectionHookDisappears() throws Exception {
    // Arrange.
    InspectionPortEntity inspectionPortElement = new InspectionPortEntity(null, ingress, egress);

    // expected before installInspectionHook
    Element registeredElement = this.redirApi.registerInspectionPort(inspectionPortElement);

    assertNotNull(registeredElement);
    assertNotNull(registeredElement.getElementId());

    final String hookId = this.redirApi.installInspectionHook(inspected, inspectionPortElement, 0L, VLAN, 0L,
            NA);

    assertNotNull(hookId);

    InspectionHookElement inspectionHookElement = this.txControl.required(() -> {
        InspectionHookElement tmpInspectionHook = this.em.find(InspectionHookEntity.class, hookId);
        return tmpInspectionHook;
    });

    assertNotNull(inspectionHookElement);
    assertEquals(hookId, inspectionHookElement.getHookId());

    assertNotNull(inspectionHookElement.getInspectionPort());
    assertEquals(registeredElement.getElementId(), inspectionHookElement.getInspectionPort().getElementId());

    // Act.
    this.redirApi.removeAllInspectionHooks(inspected);

    // Assert.
    int nInspectionHooks = this.txControl.required(() -> {
        List<InspectionHookEntity> list = this.em
                .createQuery("FROM InspectionHookEntity", InspectionHookEntity.class).getResultList();
        return list.size();
    });

    assertEquals(0, nInspectionHooks);
}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:40,代码来源:SampleSdnRedirectionApiTest.java

示例9: testApi_RemoveAllInspectionHooks_PortPairRemains

import org.osc.sdk.controller.element.Element; //导入依赖的package包/类
@Test
public void testApi_RemoveAllInspectionHooks_PortPairRemains() throws Exception {
    // Arrange.
    InspectionPortEntity inspectionPortElement = new InspectionPortEntity(null, ingress, egress);

    String inspectedId = inspected.getElementId();
    assertNotNull(inspectedId);

    this.txControl.required(() -> {
        PortEntity tmp = this.em.find(PortEntity.class, inspectedId);
        assertEquals(null, tmp);
        return null;
    });

    // expected before installInspectionHook
    Element registeredElement = this.redirApi.registerInspectionPort(inspectionPortElement);
    String elementId = registeredElement.getElementId();

    InspectionPortEntity foundInspectionPort = this.txControl.required(() -> {
        return this.em.find(InspectionPortEntity.class, elementId);
    });

    assertNotNull(foundInspectionPort);
    assertEquals(elementId, foundInspectionPort.getElementId());

    // Act.
    this.redirApi.removeAllInspectionHooks(inspected);

    // Assert.
    foundInspectionPort = this.txControl.required(() -> {
        return this.em.find(InspectionPortEntity.class, elementId);
    });

    assertNotNull(foundInspectionPort);
    assertEquals(elementId, foundInspectionPort.getElementId());
}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:37,代码来源:SampleSdnRedirectionApiTest.java

示例10: testApi_RemoveInspectionPort_InspectionPortDisappears

import org.osc.sdk.controller.element.Element; //导入依赖的package包/类
@Test
public void testApi_RemoveInspectionPort_InspectionPortDisappears() throws Exception {
    // Arrange.
    InspectionPortEntity inspectionPortElement = new InspectionPortEntity(null, ingress, egress);

    String inspectedId = inspected.getElementId();
    assertNotNull(inspectedId);

    // expected before installInspectionHook
    Element registeredElement = this.redirApi.registerInspectionPort(inspectionPortElement);

    assertTrue(registeredElement instanceof InspectionPortEntity);
    String elementId = registeredElement.getElementId();

    InspectionPortEntity foundInspectionPort = this.txControl.required(() -> {
        InspectionPortEntity tmpInspectionPort = this.em.find(InspectionPortEntity.class, elementId);
        assertNotNull(tmpInspectionPort);
        return tmpInspectionPort;
    });

    assertEquals(elementId, foundInspectionPort.getElementId());

    // Act.
    // The inspectionPortElement does not have an id. Should still work.
    this.redirApi.removeInspectionPort(inspectionPortElement);

    // Assert.
    foundInspectionPort = this.txControl.required(() -> {
        return this.em.find(InspectionPortEntity.class, elementId);
    });

    assertEquals(null, foundInspectionPort);
}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:34,代码来源:SampleSdnRedirectionApiTest.java

示例11: matches

import org.osc.sdk.controller.element.Element; //导入依赖的package包/类
@Override
public boolean matches(Object object) {
    if (object == null || !(object instanceof Element)) {
        return false;
    }

    Element element = (Element) object;
    return (element.getElementId() == null && this.id == null) || this.id.equals(element.getElementId());
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:10,代码来源:ElementIdMatcher.java

示例12: DefaultInspectionPort

import org.osc.sdk.controller.element.Element; //导入依赖的package包/类
public DefaultInspectionPort(NetworkElement ingressPort, NetworkElement egressPort, Element element) {
    this.ingressPort = ingressPort;
    this.egressPort = egressPort;
    this.elementId = (element != null ? element.getElementId() : null);
    this.parentId = (element != null ? element.getParentId() : null);
}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-api,代码行数:7,代码来源:DefaultInspectionPort.java

示例13: executeTransaction

import org.osc.sdk.controller.element.Element; //导入依赖的package包/类
@Override
public void executeTransaction(EntityManager em) throws Exception {
    this.dai = em.find(DistributedApplianceInstance.class, this.dai.getId());
    try (SdnRedirectionApi controller = this.apiFactoryService.createNetworkRedirectionApi(this.dai)) {

        DefaultNetworkPort ingressPort = new DefaultNetworkPort(this.dai.getInspectionOsIngressPortId(),
                this.dai.getInspectionIngressMacAddress());
        DefaultNetworkPort egressPort = new DefaultNetworkPort(this.dai.getInspectionOsEgressPortId(),
                this.dai.getInspectionEgressMacAddress());

        DeploymentSpec ds = this.dai.getDeploymentSpec();

        if (this.apiFactoryService.supportsNeutronSFC(this.dai.getVirtualSystem())) {
            String portGroupId = ds.getPortGroupId();
            boolean pgAlreadyCreatedByOther = (portGroupId != null);

            Element element = controller
                    .registerInspectionPort(new DefaultInspectionPort(ingressPort, egressPort, null, portGroupId));

            portGroupId = element.getParentId();

            log.info(String.format("Setting port_group_id to %s on DAI %s (id %d) for Deployment Spec %s (id: %d)",
                    portGroupId, this.dai.getName(), this.dai.getId(), ds.getName(), ds.getId()));

            if (!pgAlreadyCreatedByOther) {
                ds = em.find(DeploymentSpec.class, ds.getId());
                ds.setPortGroupId(portGroupId);
                OSCEntityManager.update(em, ds, this.txBroadcastUtil);
            }

        } else if (this.apiFactoryService.supportsPortGroup(this.dai.getVirtualSystem())) {

            String domainId = OpenstackUtil.extractDomainId(ds.getProjectId(), ds.getProjectName(),
                    ds.getVirtualSystem().getVirtualizationConnector(),
                    new ArrayList<>(Arrays.asList(ingressPort)));
            ingressPort.setParentId(domainId);
            egressPort.setParentId(domainId);
            if (domainId != null) {
                //Element Object is not used in DefaultInstepctionPort for now, hence null
                controller.registerInspectionPort(new DefaultInspectionPort(ingressPort, egressPort, null));
            } else {
                log.warn("DomainId is missing, cannot be null");
            }

        } else {
            controller.registerInspectionPort(new DefaultInspectionPort(ingressPort, egressPort, null));
        }
    }
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:50,代码来源:OnboardDAITask.java

示例14: registerInspectionPort

import org.osc.sdk.controller.element.Element; //导入依赖的package包/类
/**
 * Creates an inspection port on SDN controller.
 * The call to register the same port multiple times will result in no-op.
 * <p>
 * In case of SFC, the return element is the port pair id.
 *
 * @param inspectionPort  provides the inspection port to be created
 * @return an element
 * @throws NetworkPortNotFoundException when port is not found
 * @throws Exception upon failure
 */
Element registerInspectionPort(InspectionPortElement inspectionPort) throws NetworkPortNotFoundException, Exception;
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-api,代码行数:13,代码来源:SdnRedirectionApi.java


注:本文中的org.osc.sdk.controller.element.Element类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。