コード例 #1
0
ファイル: QoSTest.java プロジェクト: aabykov/JacORB
  public void setUpTest() throws Exception {
    trueAny = getClientORB().create_any();
    trueAny.insert_boolean(true);

    falseAny = getClientORB().create_any();
    falseAny.insert_boolean(false);

    fifoOrder = getClientORB().create_any();
    fifoOrder.insert_short(FifoOrder.value);

    lifoOrder = getClientORB().create_any();
    lifoOrder.insert_short(LifoOrder.value);

    deadlineOrder = getClientORB().create_any();
    deadlineOrder.insert_short(DeadlineOrder.value);

    priorityOrder = getClientORB().create_any();
    priorityOrder.insert_short(PriorityOrder.value);

    anyOrder = getClientORB().create_any();
    anyOrder.insert_short(AnyOrder.value);

    bestEffort = getClientORB().create_any();
    bestEffort.insert_short(BestEffort.value);

    persistent = getClientORB().create_any();
    persistent.insert_short(Persistent.value);
  }
コード例 #2
0
ファイル: IORInterceptorImpl.java プロジェクト: winsx/Payara
  public void establish_components(IORInfo info) {

    // get the OTSPolicy and InvocationPolicy objects

    OTSPolicy otsPolicy = null;

    try {
      otsPolicy = (OTSPolicy) info.get_effective_policy(OTS_POLICY_TYPE.value);
    } catch (INV_POLICY e) {
      // ignore. This implies an policy was not explicitly set.
      // A default value will be used instead.
    }

    InvocationPolicy invPolicy = null;
    try {
      invPolicy = (InvocationPolicy) info.get_effective_policy(INVOCATION_POLICY_TYPE.value);
    } catch (INV_POLICY e) {
      // ignore. This implies an policy was not explicitly set.
      // A default value will be used instead.
    }

    // get OTSPolicyValue and InvocationPolicyValue from policy objects.

    short otsPolicyValue = FORBIDS.value; // default value
    short invPolicyValue = EITHER.value; // default value

    if (otsPolicy != null) {
      otsPolicyValue = otsPolicy.value();
    }

    if (invPolicy != null) {
      invPolicyValue = invPolicy.value();
    }

    // use codec to encode policy value into an CDR encapsulation.

    Any otsAny = ORB.init().create_any();
    Any invAny = ORB.init().create_any();

    otsAny.insert_short(otsPolicyValue);
    invAny.insert_short(invPolicyValue);

    byte[] otsCompValue = null;
    byte[] invCompValue = null;
    try {
      otsCompValue = this.codec.encode_value(otsAny);
      invCompValue = this.codec.encode_value(invAny);
    } catch (InvalidTypeForEncoding e) {
      throw new INTERNAL();
    }

    // create IOR TaggedComponents for OTSPolicy and InvocationPolicy.

    TaggedComponent otsComp = new TaggedComponent(TAG_OTS_POLICY.value, otsCompValue);
    TaggedComponent invComp = new TaggedComponent(TAG_INV_POLICY.value, invCompValue);

    // add ior components.

    info.add_ior_component(otsComp);
    info.add_ior_component(invComp);
  }
コード例 #3
0
ファイル: QoSTest.java プロジェクト: aabykov/JacORB
  /**
   * test if events are reorderd respecting their priority. a supplier pushes some events with
   * ascending priority into a channel that was setup with OrderPolicy=PriorityOrder. A Consumer
   * receives and checks if the Events are delivered in descending Priority order.
   */
  public void testPriorityOrder() throws Exception {

    // create and setup channel
    IntHolder channelId = new IntHolder();

    Property[] qosProps;

    qosProps = new Property[] {new Property(OrderPolicy.value, priorityOrder)};

    EventChannel channel =
        getEventChannelFactory().create_channel(qosProps, new Property[0], channelId);

    // testdata
    StructuredEvent[] events = new StructuredEvent[10];
    for (int x = 0; x < events.length; ++x) {
      events[x] = new NotificationTestUtils(getClientORB()).getStructuredEvent();

      Any priority = getClientORB().create_any();
      priority.insert_short((short) x);

      events[x].header.variable_header = new Property[] {new Property(Priority.value, priority)};
    }

    final List received = new ArrayList();

    // setup clients
    StructuredPushReceiver receiver =
        new StructuredPushReceiver(this.getClientORB(), events.length) {
          public void push_structured_event(StructuredEvent event) throws Disconnected {
            super.push_structured_event(event);

            received.add(event);
          }
        };

    receiver.connect(channel, false);

    receiver.pushSupplier_.suspend_connection();

    StructuredPushSender sender = new StructuredPushSender(this.getClientORB());

    sender.setStructuredEvent(events);
    sender.setInterval(100);

    sender.connect(channel, false);

    // push events
    sender.run();

    assertFalse(receiver.isEventHandled());

    Thread.sleep(2000);

    receiver.pushSupplier_.resume_connection();

    receiver.setTimeOut(events.length * 1000);

    receiver.run();

    assertTrue(receiver.isEventHandled());

    Thread.sleep(2000);

    while (!received.isEmpty()) {
      StructuredEvent event = (StructuredEvent) received.remove(0);

      Iterator i = received.iterator();
      while (i.hasNext()) {
        short p1 = event.header.variable_header[0].value.extract_short();

        short p2 = ((StructuredEvent) i.next()).header.variable_header[0].value.extract_short();

        assertTrue(p1 + " > " + p2, p1 > p2);
      }
    }
  }