Package net.jini.space

Examples of net.jini.space.MatchSet


    protected Entry[] getEntryArray() {
      try {
  List acc = new java.util.LinkedList();
  if (proxy instanceof JavaSpace05) {
    MatchSet set =
      ((JavaSpace05) proxy).contents(Collections.singleton(null),
             null, Lease.ANY, Integer.MAX_VALUE);
    Lease lease = set.getLease();
    if (lease != null) {
      lease = (Lease) browser.leasePreparer.prepareProxy(lease);
      browser.leaseMgr.renewUntil(lease, Lease.ANY, null);
    }
    try {
      while (true) {
        try {
    Entry e = set.next();
    if (e == null)
      break;
    acc.add(e);
        } catch (UnusableEntryException e) {
    Browser.logger.log(Level.INFO, "unusable entry", e);
View Full Code Here


      logger.log(Level.INFO,
           nameAndTrail() + "looking for " + tbf.size() + " entries");
      logger.log(Level.INFO,
           nameAndTrail() + "using:" + TestEntries.toString(tmpls));

      final MatchSet cr;
      final Lease l;
      TestEntry e;
      try {
    cr = space.contents(tmpls, null, 60000, Long.MAX_VALUE);
   
    l = cr.getLease();
    if (tbf.size() < batchSize && l != null) {
        throw failure(
      "failed! got lease, but should not have. tbf.size:" +
      tbf.size());
    } else if (tbf.size() >= batchSize && l == null) {
        throw failure(
       "failed! did not get lease, but should have. tbf.size:" +
       tbf.size());
    }
       
    if (l != null) {
        lrm.renewFor(l, Long.MAX_VALUE, 60000, null);
    }

    e = (TestEntry)cr.next();
      } catch (Throwable t) {
    throw failure("failed with " + t + " during contents call phase",
            t);
      }

      while (e != null) {
    if (!tbf.remove(e)) {
        throw failure("failed, " + TestEntries.toString(e) +
          " not in tbf");
    }
   
    try {
        e = (TestEntry)cr.next();
    } catch (Throwable t) {     
        throw failure("failed with " + t + " during next call", t);
    }
      }
View Full Code Here

      logger.log(Level.INFO,
           nameAndTrail() + "looking for " + tbf.size() + " entries");
      logger.log(Level.INFO,
           nameAndTrail() + "using:" + TestEntries.toString(tmpls));

      final MatchSet cr;
      final Lease l;
      TestEntry e;
      try {
    cr = space.contents(tmpls, null, 60000, Long.MAX_VALUE);

    l = cr.getLease();
    if (tbf.size() < batchSize && l != null) {
        throw failure(
            "failed! got lease, but should not have. tbf.size:" +
      tbf.size());
    } else if (tbf.size() >= batchSize && l == null) {
        throw failure(
                        "failed! did not get lease, but should have. tbf.size:"
      + tbf.size());
    }
       
    if (l != null) {
        lrm.renewFor(l, Long.MAX_VALUE, 60000, null);
    }

    e = (TestEntry)cr.next();
      } catch (Throwable t) {
    throw failure("failed with " + t + " during contents call phase",
            t);
      }

      final LinkedList notInTBF = new LinkedList();
     
      while (e != null) {
    if (!tbf.remove(e)) {
        notInTBF.add(e);
       
        // Make sure all the extras match
        boolean found = TestEntries.isMatch(tmpls, e);
        if (!found) {
      throw failure("failed. " + TestEntries.toString(e) +
              " did not match any templates");
        }          
    }

    try {
        e = (TestEntry)cr.next();
    } catch (Throwable t) {     
        throw failure("failed with " + t + " during next call", t);
    }
      }
View Full Code Here

         * that an entry is removed from match set after performing
         * MatchSet.next() method
         */
        JavaSpace05 space05 = (JavaSpace05) space;
        templates.add(sampleEntry1);
        MatchSet matchSet = space05.contents(templates, null, Lease.ANY,
                                             MAX_ENTRIES);
        if (matchSet.next() == null) {
            throw new TestException("Match set is exhausted. "
                                    + "But it shouldn't be.");
        }

        // now it is supposed to be exhausted
        if (matchSet.next() != null) {
            throw new TestException("Match set was not exhausted. "
                                    + "But should have been.");
        }
        space.write(sampleEntry1, null, leaseForeverTime);
        Thread.sleep(1000);
        if (matchSet.next() != null) {
            throw new TestException("An entry added to exhausted match set. "
                                    + "But must not have been.");
        }
        reset();

        /*
         * After maxEntries entries are yielded by next invocations the match
         * set becomes empty. For this test case let maxEntries = 2
         */
        templates.add(null);    // for 3 existing entries
        matchSet = space05.contents(templates, null, Lease.ANY, 2);
        matchSet.next();
        matchSet.next();
        if (matchSet.next() != null) {
            throw new TestException("Match set is not empty after maxEntries "
                                    + "are yielded by next invocations");
        }
        reset();

        /*
         * The initial duration of the lease must be less than or equal to
         * leaseDuration. Let leaseDuration = instantTime.
         */
        templates.add(null);    // for 3 existing entries
        matchSet = space05.contents(templates, null, leaseForeverTime,
                                    MAX_ENTRIES);
        Lease lease = matchSet.getLease();
        if (lease != null) {
            long initialDuration = lease.getExpiration()
                    - System.currentTimeMillis();
            if (initialDuration > leaseForeverTime) {
                throw new TestException("Initial duration of the lease "
View Full Code Here

                               List expectedResult,
                               String testName) throws Exception
    {

        JavaSpace05 space05 = (JavaSpace05) space;
        MatchSet matchSet = space05.contents(templates, txn, leaseDuration,
                                             maxEntries);
        ArrayList result = new ArrayList();
        SimpleEntry entry = (SimpleEntry) matchSet.next();
        while (entry != null) {
            result.add(entry);
            entry = (SimpleEntry) matchSet.next();
        }
        if (result.size() != expectedResult.size()) {
            throw new TestException(testName + " failed. "
                                    + "Taken result is not as expected.");
        }
View Full Code Here

    protected Entry[] getEntryArray() {
      try {
  List acc = new java.util.LinkedList();
  if (proxy instanceof JavaSpace05) {
    MatchSet set =
      ((JavaSpace05) proxy).contents(Collections.singleton(null),
             null, Lease.ANY, Integer.MAX_VALUE);
    Lease lease = set.getLease();
    if (lease != null) {
      lease = (Lease) browser.leasePreparer.prepareProxy(lease);
      browser.leaseMgr.renewUntil(lease, Lease.ANY, null);
    }
    try {
      while (true) {
        try {
    Entry e = set.next();
    if (e == null)
      break;
    acc.add(e);
        } catch (UnusableEntryException e) {
    Browser.logger.log(Level.INFO, "unusable entry", e);
View Full Code Here

         * MatchSet.next() method
         */
        JavaSpace05 space05 = (JavaSpace05) space;
        templates.add(sampleEntry1);
        txn = getTransaction();
        MatchSet matchSet = space05.contents(templates, txn, Lease.ANY,
                                             MAX_ENTRIES);
        if (matchSet.next() == null) {
            throw new TestException(
                    "Match set is exhausted. But it shouldn't be.");
        }

        // -- now it is supposed to be exhausted
        if (matchSet.next() != null) {
            throw new TestException(
                    "Match set was not exhausted. But should have been.");
        }
        space.write(sampleEntry1, txn, leaseForeverTime);
        Thread.sleep(1000);
        if (matchSet.next() != null) {
            throw new TestException("An entry added to exhausted match set. "
                                    + "But must not have been.");
        }
        txn.commit();
        reset();

        /*
         * After maxEntries entries are yielded by next invocations the match
         * set becomes empty. For this test case let maxEntries = 2
         */
        templates.add(null);    // for 3 existing entries
        txn = getTransaction();
        matchSet = space05.contents(templates, txn, Lease.ANY, 2);
        matchSet.next();
        matchSet.next();
        if (matchSet.next() != null) {
            throw new TestException("Match set is not empty after maxEntries "
                                    + "are yielded by next invocations");
        }
        txn.commit();
        reset();

        /*
         * The initial duration of the lease must be less than or equal to
         * leaseDuration. Let leaseDuration = instantTime.
         */
        templates.add(null);    // for 3 existing entries
        txn = getTransaction();
        matchSet = space05.contents(templates, txn, leaseForeverTime,
                                    MAX_ENTRIES);
        Lease lease = matchSet.getLease();
        if (lease != null) {
            long initialDuration = lease.getExpiration()
                    - System.currentTimeMillis();
            if (initialDuration > leaseForeverTime) {
                throw new TestException("Initial duration of the lease "
                                        + "is more than leaseDuration");
            }
        } // else Lease is not tested as the matchset is not leased
        txn.commit();
        reset();

        //corresponds to item #6 in this method's comments
        txn = getTransaction();
        templates.add((SimpleEntry) sampleEntry1.clone());
        matchSet = space05.contents(templates, txn, leaseForeverTime,
                                    MAX_ENTRIES);
        matchSet.next();
        SimpleEntry entry = (SimpleEntry) space.take(
                (SimpleEntry) sampleEntry1.clone(), null, instantTime);
        if (entry != null) {
            throw new TestException("Locked entry can be taken "
                                    + "from the space.");
View Full Code Here

    {
        if (txn == null) {
            throw new TestException("Transaction is null for test " + testName);
        }
        JavaSpace05 space05 = (JavaSpace05) space;
        MatchSet matchSet = space05.contents(templates, txn, leaseDuration,
                                             maxEntries);
        ArrayList result = new ArrayList();
        SimpleEntry entry = (SimpleEntry) matchSet.next();
        while (entry != null) {
            result.add(entry);
            entry = (SimpleEntry) matchSet.next();
        }

        if (result.size() != expectedResult.size()) {
            throw new TestException(testName + " failed. "
                                    + "Taken result is not as expected.");
View Full Code Here

TOP

Related Classes of net.jini.space.MatchSet

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.