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


Java Notification类代码示例

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


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

示例1: issueNotification

import org.opendaylight.yangtools.yang.binding.Notification; //导入依赖的package包/类
/**
 * Issue notification to the specified list of Uris
 * @param value - Notification to issue
 * @param uris - Uris to issue the notification to
 */
static protected void issueNotification(Value value, Collection<Uri> uris) {
    Long notificationId = NotificationInfo.next();
    Notify notif = new NotifyBuilder()
            .setNotificationId(new NotificationId(notificationId))
            .setTimestamp(BigInteger.valueOf(System.currentTimeMillis()))
            .setValue(value)
            .build();

    for(Uri uri : uris) {
        if (uri!=null && uri.getValue().startsWith("http") &&
                (HTTPClientPool.instance() != null)) {
                try {
                    HTTPClientPool.instance().getWorker().getQueue().put(
                        new AbstractMap.SimpleEntry<Uri,Notification>(
                                uri,
                                notif));
                } catch (InterruptedException e) {
                	ErrorLog.logError(e.getStackTrace());
                } catch (Exception ee) {
                	ErrorLog.logError(ee.getMessage(),ee.getStackTrace());
                }
            }
    }
}
 
开发者ID:opendaylight,项目名称:fpc,代码行数:30,代码来源:Notifier.java

示例2: NotificationInvoker

import org.opendaylight.yangtools.yang.binding.Notification; //导入依赖的package包/类
private NotificationInvoker(final NotificationListener listener) {
    delegate = listener;
    final Map<Class<? extends Notification>, InvokerContext> builder = new HashMap<>();
    for(final TypeToken<?> ifaceToken : TypeToken.of(listener.getClass()).getTypes().interfaces()) {
        final Class<?> iface = ifaceToken.getRawType();
        if(NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
            @SuppressWarnings("unchecked")
            final Class<? extends NotificationListener> listenerType = (Class<? extends NotificationListener>) iface;
            final NotificationListenerInvoker invoker = NotificationListenerInvoker.from(listenerType);
            for(final Class<? extends Notification> type : getNotificationTypes(listenerType)) {
                builder.put(type, new InvokerContext(BindingReflections.findQName(type) , invoker));
            }
        }
    }
    invokers = ImmutableMap.copyOf(builder);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:NotificationInvoker.java

示例3: getNotificationClasses

import org.opendaylight.yangtools.yang.binding.Notification; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Set<Class<? extends Notification>> getNotificationClasses(final Set<SchemaPath> interested) {
    final Set<Class<? extends Notification>> result = new HashSet<>();
    final Set<NotificationDefinition> knownNotifications = runtimeContext().getSchemaContext().getNotifications();
    for (final NotificationDefinition notification : knownNotifications) {
        if (interested.contains(notification.getPath())) {
            try {
                result.add((Class<? extends Notification>) runtimeContext().getClassForSchema(notification));
            } catch (final IllegalStateException e) {
                // Ignore
                LOG.warn("Class for {} is currently not known.", notification.getPath(), e);
            }
        }
    }
    return result;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:BindingToNormalizedNodeCodec.java

示例4: setUp

import org.opendaylight.yangtools.yang.binding.Notification; //导入依赖的package包/类
@Before
public void setUp() {
    this.ctx = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance();
    final MessageRegistry msgRegistry = this.ctx.getMessageRegistry();
    this.parser = new AbstractBmpPerPeerMessageParser<Builder<?>>(msgRegistry) {
        @Override
        public Notification parseMessageBody(final ByteBuf bytes) {
            return null;
        }

        @Override
        public int getBmpMessageType() {
            return 0;
        }
    };
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:17,代码来源:AbstractBmpPerPeerMessageParserTest.java

示例5: parseBgpNotificationMessage

import org.opendaylight.yangtools.yang.binding.Notification; //导入依赖的package包/类
private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.down.data
        .Notification parseBgpNotificationMessage(final ByteBuf bytes) throws BmpDeserializationException {
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.down.data
            .NotificationBuilder notificationCBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params
            .xml.ns.yang.bmp.message.rev171207.peer.down.data.NotificationBuilder();

    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.down.data
            .notification.NotificationBuilder notificationBuilder = new org.opendaylight.yang.gen.v1.urn
            .opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.down.data.notification
            .NotificationBuilder();
    try {
        final Notification not = this.msgRegistry.parseMessage(bytes, null);
        requireNonNull(not, "Notify message may not be null.");
        Preconditions.checkArgument(not instanceof NotifyMessage,
                "An instance of NotifyMessage is required");
        notificationBuilder.fieldsFrom((NotifyMessage) not);
        notificationCBuilder.setNotification(notificationBuilder.build());
    } catch (final BGPDocumentedException | BGPParsingException e) {
        throw new BmpDeserializationException("Error while parsing BGP Notification message.", e);
    }

    return notificationCBuilder.build();
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:24,代码来源:PeerDownHandler.java

示例6: testSimpleMessageRegistry

import org.opendaylight.yangtools.yang.binding.Notification; //导入依赖的package包/类
@Test
public void testSimpleMessageRegistry() throws Exception {
    final MessageRegistry msgRegistry = this.ctx.getMessageRegistry();

    final byte[] msgBytes = {
        (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
        (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
        (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
        (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
        (byte) 0x00, (byte) 0x13, (byte) 0x00
    };
    final Notification msg = mock(Notification.class);
    doReturn(Notification.class).when(msg).getImplementedInterface();

    final ByteBuf buffer = Unpooled.buffer(msgBytes.length);
    msgRegistry.serializeMessage(msg, buffer);
    msgRegistry.parseMessage(Unpooled.wrappedBuffer(msgBytes), CONSTRAINT);
    verify(this.activator.msgParser, times(1)).parseMessageBody(Mockito.any(ByteBuf.class), Mockito.anyInt(),
        Mockito.any(PeerSpecificParserConstraint.class));
    verify(this.activator.msgSerializer, times(1)).serializeMessage(Mockito.any(Notification.class), Mockito.any(ByteBuf.class));
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:22,代码来源:SimpleRegistryTest.java

示例7: parseMessageBody

import org.opendaylight.yangtools.yang.binding.Notification; //导入依赖的package包/类
@Override
public Notification parseMessageBody(final ByteBuf bytes) throws BmpDeserializationException {
    final InitiationMessageBuilder initiationBuilder = new InitiationMessageBuilder();
    final TlvsBuilder tlvsBuilder = new TlvsBuilder();
    tlvsBuilder.setStringInformation(ImmutableList.of());
    parseTlvs(tlvsBuilder, bytes);

    if (tlvsBuilder.getDescriptionTlv() == null || tlvsBuilder.getDescriptionTlv().getDescription() == null) {
        throw new BmpDeserializationException("Inclusion of sysDescr TLV is mandatory.");
    }
    if (tlvsBuilder.getNameTlv() == null || tlvsBuilder.getNameTlv().getName() == null) {
        throw new BmpDeserializationException("Inclusion of sysName TLV is mandatory.");
    }

    return initiationBuilder.setTlvs(tlvsBuilder.build()).build();
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:17,代码来源:InitiationHandler.java

示例8: serializeMessageBody

import org.opendaylight.yangtools.yang.binding.Notification; //导入依赖的package包/类
@Override
public void serializeMessageBody(final Notification message, final ByteBuf buffer) {
    super.serializeMessageBody(message, buffer);
    Preconditions.checkArgument(message instanceof PeerUpNotification,
        "An instance of Peer Up notification is required");
    final PeerUpNotification peerUp = (PeerUpNotification) message;

    if (peerUp.getLocalAddress().getIpv4Address() != null) {
        buffer.writeZero(Ipv6Util.IPV6_LENGTH - Ipv4Util.IP4_LENGTH);
        ByteBufWriteUtil.writeIpv4Address(peerUp.getLocalAddress().getIpv4Address(), buffer);
    } else {
        ByteBufWriteUtil.writeIpv6Address(peerUp.getLocalAddress().getIpv6Address(), buffer);
    }
    ByteBufWriteUtil.writeUnsignedShort(peerUp.getLocalPort().getValue(), buffer);
    ByteBufWriteUtil.writeUnsignedShort(peerUp.getRemotePort().getValue(), buffer);

    this.msgRegistry.serializeMessage(new OpenBuilder(peerUp.getSentOpen()).build(), buffer);
    this.msgRegistry.serializeMessage(new OpenBuilder(peerUp.getReceivedOpen()).build(), buffer);
    serializeTlvs(peerUp.getInformation(), buffer);
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:21,代码来源:PeerUpHandler.java

示例9: parseMessageBody

import org.opendaylight.yangtools.yang.binding.Notification; //导入依赖的package包/类
@Override
public Notification parseMessageBody(final ByteBuf bytes) throws BmpDeserializationException {
    final RouteMonitoringMessageBuilder routeMonitor = new RouteMonitoringMessageBuilder()
            .setPeerHeader(parsePerPeerHeader(bytes));
    try {
        final Notification message = this.msgRegistry.parseMessage(bytes, null);
        requireNonNull(message, "UpdateMessage may not be null");
        Preconditions.checkArgument(message instanceof UpdateMessage,
                "An instance of UpdateMessage is required");
        final UpdateMessage updateMessage = (UpdateMessage) message;
        final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.route
                .monitoring.message.Update update = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
                .ns.yang.bmp.message.rev171207.route.monitoring.message.UpdateBuilder(updateMessage).build();
        routeMonitor.setUpdate(update);
    } catch (final BGPDocumentedException | BGPParsingException e) {
        throw new BmpDeserializationException("Error while parsing Update Message.", e);
    }

    return routeMonitor.build();
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:21,代码来源:RouteMonitoringMessageHandler.java

示例10: setUp

import org.opendaylight.yangtools.yang.binding.Notification; //导入依赖的package包/类
@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    this.messages = Lists.newArrayList();
    this.session = new BmpMockSession(1, 1, 1);
    this.channel = Mockito.mock(Channel.class);
    Mockito.doReturn(REMOTE_ADDRESS).when(this.channel).remoteAddress();
    Mockito.doReturn(LOCAL_ADDRESS).when(this.channel).localAddress();
    final ChannelPipeline pipeline = Mockito.mock(ChannelPipeline.class);
    Mockito.doReturn(pipeline).when(this.channel).pipeline();
    Mockito.doAnswer(invocation -> {
        messages.add((Notification) invocation.getArguments()[0]);
        return null;
    }).when(this.channel).writeAndFlush(Mockito.any());
    final ChannelFuture channelFuture = Mockito.mock(ChannelFuture.class);
    Mockito.doReturn(null).when(channelFuture).addListener(Mockito.any());
    Mockito.doReturn(channelFuture).when(this.channel).closeFuture();
    Mockito.doReturn(channelFuture).when(this.channel).close();
    this.context = Mockito.mock(ChannelHandlerContext.class);
    Mockito.doReturn(this.channel).when(this.context).channel();
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:22,代码来源:BmpMockSessionTest.java

示例11: testErrorOneOne

import org.opendaylight.yangtools.yang.binding.Notification; //导入依赖的package包/类
/**
 * Sending different PCEP Message than Open in session establishment phase.
 *
 * @throws Exception exception
 */
@Test
public void testErrorOneOne() throws Exception {
    this.serverSession.channelActive(null);
    assertEquals(1, this.msgsSend.size());
    assertTrue(this.msgsSend.get(0) instanceof Open);
    this.serverSession.handleMessage(this.kaMsg);
    checkEquals(()-> {
        for (final Notification m : this.msgsSend) {
            if (m instanceof Pcerr) {
                final Errors obj = ((Pcerr) m).getPcerrMessage().getErrors().get(0);
                assertEquals(new Short((short) 1), obj.getErrorObject().getType());
                assertEquals(new Short((short) 1), obj.getErrorObject().getValue());
            }
        }
    });
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:22,代码来源:FiniteStateMachineTest.java

示例12: testErrorOneSeven

import org.opendaylight.yangtools.yang.binding.Notification; //导入依赖的package包/类
/**
 * KeepWaitTimer expired.
 *
 * @throws Exception exception
 */
@Test
public void testErrorOneSeven() throws Exception {
    this.serverSession.channelActive(null);
    assertEquals(1, this.msgsSend.size());
    assertTrue(this.msgsSend.get(0) instanceof Open);
    this.serverSession.handleMessage(this.openMsg);
    checkEquals(() -> {
        for (final Notification m : this.msgsSend) {
            if (m instanceof Pcerr) {
                final Errors obj = ((Pcerr) m).getPcerrMessage().getErrors().get(0);
                assertEquals(new Short((short) 1), obj.getErrorObject().getType());
                assertEquals(new Short((short) 7), obj.getErrorObject().getValue());
            }
        }
    });
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:22,代码来源:FiniteStateMachineTest.java

示例13: testErrorOneTwo

import org.opendaylight.yangtools.yang.binding.Notification; //导入依赖的package包/类
/**
 * OpenWait timer expired.
 *
 * @throws InterruptedException exception
 */
@Test
public void testErrorOneTwo() throws Exception {
    this.serverSession.channelActive(null);
    assertEquals(1, this.msgsSend.size());
    assertTrue(this.msgsSend.get(0) instanceof OpenMessage);
    checkEquals(() -> {
        for (final Notification m : this.msgsSend) {
            if (m instanceof Pcerr) {
                final Errors obj = ((Pcerr) m).getPcerrMessage().getErrors().get(0);
                assertEquals(new Short((short) 1), obj.getErrorObject().getType());
                assertEquals(new Short((short) 2), obj.getErrorObject().getValue());
            }
        }
    });
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:21,代码来源:FiniteStateMachineTest.java

示例14: serializeMessage

import org.opendaylight.yangtools.yang.binding.Notification; //导入依赖的package包/类
/**
 * Serializes BGP Notification message.
 *
 * @param msg to be serialized
 * @param bytes ByteBuf where the message will be serialized
 */
@Override
public void serializeMessage(final Notification msg, final ByteBuf bytes) {
    Preconditions.checkArgument(msg instanceof Notify, "Message needs to be of type Notify");
    final Notify ntf = (Notify) msg;

    final ByteBuf msgBody = Unpooled.buffer();
    msgBody.writeByte(ntf.getErrorCode());
    msgBody.writeByte(ntf.getErrorSubcode());
    final byte[] data = ntf.getData();
    if (data != null) {
        msgBody.writeBytes(data);
    }
    LOG.trace("Notification message serialized to: {}", ByteBufUtil.hexDump(msgBody));
    MessageUtil.formatMessage(TYPE, msgBody, bytes);
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:22,代码来源:BGPNotificationMessageParser.java

示例15: testNoAs4BytesCapability

import org.opendaylight.yangtools.yang.binding.Notification; //导入依赖的package包/类
@Test
public void testNoAs4BytesCapability() {
    this.clientSession.channelActive(null);
    assertEquals(1, this.receivedMsgs.size());
    assertTrue(this.receivedMsgs.get(0) instanceof Open);

    final List<BgpParameters> tlvs = Lists.newArrayList();
    final List<OptionalCapabilities> capas = Lists.newArrayList();
    capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class,
        new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder()
            .setAfi(this.ipv4tt.getAfi()).setSafi(this.ipv4tt.getSafi()).build()).build()).build()).build());
    capas.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
    tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
    // Open Message without advertised four-octet AS Number capability
    this.clientSession.handleMessage(new OpenBuilder().setMyAsNumber(30).setHoldTimer(1).setVersion(
        new ProtocolVersion((short) 4)).setBgpParameters(tlvs).setBgpIdentifier(new Ipv4Address("1.1.1.2")).build());
    assertEquals(2, this.receivedMsgs.size());
    assertTrue(this.receivedMsgs.get(1) instanceof Notify);
    final Notification m = this.receivedMsgs.get(this.receivedMsgs.size() - 1);
    assertEquals(BGPError.UNSUPPORTED_CAPABILITY, BGPError.forValue(((Notify) m).getErrorCode(), ((Notify) m).getErrorSubcode()));
    assertNotNull(((Notify) m).getData());
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:23,代码来源:FSMTest.java


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