Package java.rmi

Examples of java.rmi.MarshalledObject$MarshalledObjectOutputStream


            for (j=0;j<nSrvcsPerClass;j++) {
                n = k%(attrEntries.length);
          tmpl[k] = new ServiceTemplate(null,null,tmplAttrs[n]);
    setStateAttrInfo(k,n,tmplAttrs,state);
    proxy.notify(tmpl[k],transitionMask,listener,
           new MarshalledObject
         (new QATestUtils.SrvcAttrTuple
             (srvcItems[k].service,
              tmplAttrs[n][0])),
           Long.MAX_VALUE);
                k++;
View Full Code Here


  // create a lease renewal set
  LeaseRenewalSet set = lrs.createLeaseRenewalSet(renewSetDur);
  set = prepareSet(set);

  // create a handback object
  MarshalledObject handback = new MarshalledObject(new Integer(99));

  // register listener to receive events
  EventRegistration evReg =
      set.setExpirationWarningListener(rrl, minWarning, handback);
  evReg = prepareRegistration(evReg);

  if (rstUtil.isValidExpWarnEventReg(evReg, set) == false) {
      String message = "Event Registration is invalid.";
      message += rstUtil.getFailureReason();
      throw new TestException(message);
  }

  // allow the set's lease to expire
  rstUtil.waitForRemoteEvents(rrl, 1, renewSetDur);

  /* Assert that the notification was received at approximately
     the lease expiration time - minWarning */
  Long[] arrivalTimes = rrl.getArrivalTimes();

  // must at lease have received one event
  if (arrivalTimes.length == 0) {
      String message = "ExpirationWarning event never received.";
      throw new TestException(message);
  }

  // must NOT have received more than one event
  if (arrivalTimes.length > 1) {
      String message = "Too many events received.";
      throw new TestException(message);
  }

  /* TESTING ASSERTION #1
     was the event received around the right time? */
  String prop = "com.sun.jini.test.spec.renewalservice." +
         "slop_percent_tolerance";
  int tolerance =
      getConfig().getIntConfigVal(prop, SLOP_PERCENT_TOLERANCE);
  logger.log(Level.FINE, "Allowing a slop tolerance of (+/-)" +
        tolerance + "% of expected warning time.");

  long leaseExpiration = prepareLease(set.getRenewalSetLease()).getExpiration();
  long idealArrival = leaseExpiration - minWarning;
  long arrivalSlop = minWarning * tolerance / 100;
  long minAllowed = idealArrival - arrivalSlop;
  long maxAllowed = idealArrival + arrivalSlop;
  long actualArrivalTime = arrivalTimes[0].longValue();

  if (actualArrivalTime > minAllowed &&
      actualArrivalTime < maxAllowed) {
      // we say event was received around the right time
      logger.log(Level.FINE, "Assertion #1 passes!");
  } else {
      /* There was a lag. This could be network problem or an
         overloaded cpu but we will just have to assume that the
         specification was not met. */
      String message = "Assertion #1 failed ...\n";
      message += "Event was not received +/- " + arrivalSlop;
      message += " milliseconds.";
      throw new TestException(message);
  }

  /* TESTING ASSERTION #2
     the handback object is the one we expect. */
  RemoteEvent[] events = rrl.getEvents();
  MarshalledObject mObj = events[0].getRegistrationObject();
  if (handback.equals(mObj) == false) {
      String message = "Assertion #2 failed ...\n";
      message += "Handback object does not match original.";
      throw new TestException(message);
  }
View Full Code Here

            return (new RegTuple(regs,mRegs,exceptions,groupsMap));
        }//end getRegistrars

        private void setRegInfoHandback(RemoteDiscoveryEvent evnt) {
            int iHandback = -1;//for null handbacks
            MarshalledObject mHandback = evnt.getRegistrationObject();
            if(mHandback != null) {
                try {
                    Integer handback = (Integer)mHandback.get();
                    iHandback = handback.intValue();
                } catch (ClassNotFoundException e) {
                    logger.log(Level.FINE, "WARNING - failure while "
                                +"un-marshalling event handback information "
                                +"(ClassNotFoundException)");
View Full Code Here

       set1 = prepareSet(set1);
       set2 = lrs02.createLeaseRenewalSet(Lease.FOREVER);
       set2 = prepareSet(set2);
       set3 = lrs01.createLeaseRenewalSet(Lease.FOREVER);
       set3 = prepareSet(set3);
       MarshalledObject marshObj = new MarshalledObject(set1);
       set4 = (LeaseRenewalSet) marshObj.get();
       set4 = prepareSet(set4);

    }
View Full Code Here

            if (wcb != null) {
                rcb = wcb.writeCallback(or, constraints);
            }
            ObjectOutputStream oos =
                new ObjectOutputStream(or.getRequestOutputStream());
            oos.writeObject(new MarshalledObject(rcb));
            oos.flush();
            Util.log(Util.RETURN, "returned OutboundRequest: " + or);
            Util.log(Util.CALLS, "Leaving Endpoint.newRequest");
            index++;
            return or;
View Full Code Here

        for(int i=0;i<attrs.length;i++) {
            /* Do not let an attribute problem prevent the service from
             * continuing to operate
             */
            try {
                marshalledAttrs.add(new MarshalledObject(attrs[i]));
            } catch(Throwable e) {
                if( problemLogger.isLoggable(Level.INFO) ) {
                    problemLogger.log(Level.INFO,
                                      "Error while marshalling attribute["+i
                                      +"] ("+attrs[i]+")", e);
View Full Code Here

            /*
             * Marshalling errors should not prevent the service from
             * working, so just ignore them.
             */
            try {
                marshalledAttrs.add(new MarshalledObject(attrs[i]));
            } catch(Throwable e) {
          if (recoveryLogger.isLoggable(Levels.HANDLED)) {
                    recoveryLogger.log(Levels.HANDLED,
                        "Error while marshalling attribute[{0}]: {1}",
      new Object[] {new Integer(i), attrs[i]});
View Full Code Here

                Map.Entry pair = (Map.Entry)itr.next();
                ServiceRegistrar reg = (ServiceRegistrar)pair.getKey();
                /* If reg is already in map, go to next registrar */
                if( discoveredRegsMap.containsKey(reg) ) continue nextReg;
                /* It doesn't contain it, try to marshal it */
                MarshalledObject mReg = null;
                try {
                    mReg = new MarshalledObject(reg);
                } catch(IOException e) { continue nextReg; } //failed, next reg
                /* Succeeded, map registrar to its marshalled form */
                discoveredRegsMap.put(reg,mReg);
                /* Map the registrar to its member groups for the return map */
                regMapOut.put(reg,
View Full Code Here

         *  is separate from the normal mechanism applied to the remaining
         *  fields of this class.
         */
        private void writeObject(ObjectOutputStream stream) throws IOException{
            stream.defaultWriteObject();
            stream.writeObject(new MarshalledObject(listener));
        }//end writeObject
View Full Code Here

         */
        private void readObject(ObjectInputStream stream)
                                    throws IOException, ClassNotFoundException
        {
            stream.defaultReadObject();
            MarshalledObject mo = (MarshalledObject)stream.readObject();
            try {
                listener = (RemoteEventListener)mo.get();
                /* Re-prepare the recovered listener */
                listener =
                 (RemoteEventListener)recoveredListenerPreparer.prepareProxy
                                                                   (listener);
            } catch (Throwable e) {
View Full Code Here

TOP

Related Classes of java.rmi.MarshalledObject$MarshalledObjectOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.