Package com.sun.sgs.impl.service.data.store

Examples of com.sun.sgs.impl.service.data.store.BindingValue


      if (logger.isLoggable(FINEST)) {
    logger.log(FINEST, "getBinding txn:{0}, name:{1}", txn, name);
      }
      try {
    checkNull("name", name);
    BindingValue result = super.getBindingInternal(txn, name);
    if (logger.isLoggable(FINEST)) {
        logger.log(FINEST,
             "getBinding txn:{0}, name:{1} returns " +
             "oid:{2,number,#}",
             txn, name, result.getObjectId());
    }
    return result;
      } catch (RuntimeException e) {
    throw handleException(
        txn, FINEST, e,
View Full Code Here


        FINEST, "setBinding txn:{0}, name:{1}, oid:{2,number,#}",
        txn, name, oid);
      }
      try {
    checkNull("name", name);
    BindingValue result = super.setBindingInternal(txn, name, oid);
    if (logger.isLoggable(FINEST)) {
        logger.log(FINEST,
             "setBinding txn:{0}, name:{1}," +
             " oid:{2,number,#} returns",
             txn, name, oid);
View Full Code Here

    logger.log(
        FINEST, "removeBinding txn:{0}, name:{1}", txn, name);
      }
      try {
    checkNull("name", name);
    BindingValue result = super.removeBindingInternal(txn, name);
    if (logger.isLoggable(FINEST)) {
        logger.log(FINEST,
             "removeBinding txn:{0}, name:{1} returns {2}",
             txn, name, result);
    }
View Full Code Here

    private void handleGetBinding(DataStoreServer server) throws IOException {
  try {
      long tid = in.readLong();
      String name = readString(in);
      BindingValue result = server.getBinding(tid, name);
      out.writeBoolean(true);
      writeBindingValue(result);
      out.flush();
  } catch (Throwable t) {
      failure(t);
View Full Code Here

    private void handleSetBinding(DataStoreServer server) throws IOException {
  try {
      long tid = in.readLong();
      String name = readString(in);
      long oid = in.readLong();
      BindingValue result = server.setBinding(tid, name, oid);
      out.writeBoolean(true);
      writeBindingValue(result);
      out.flush();
  } catch (Throwable t) {
      failure(t);
View Full Code Here

  throws IOException
    {
  try {
      long tid = in.readLong();
      String name = readString(in);
      BindingValue result = server.removeBinding(tid, name);
      out.writeBoolean(true);
      writeBindingValue(result);
      out.flush();
  } catch (Throwable t) {
      failure(t);
View Full Code Here

  out.flush();
    }

    /** Read a BindingValue from input. */
    private BindingValue readBindingValue() throws IOException {
  return new BindingValue(in.readLong(), readString(in));
    }
View Full Code Here

    @Override
    protected BindingValue getBindingInternal(Transaction txn, String name) {
  TxnContext context = contextMap.join(txn);
  long stop = context.getStopTime();
  BindingKey nameKey = BindingKey.get(name);
  BindingValue result;
  for (int i = 0; true; i++) {
      if (i >= MAX_CACHE_RETRIES) {
    throw new ResourceUnavailableException("Too many retries");
      }
      /* Find cache entry for name or next higher name */
      BindingCacheEntry entry = cache.getCeilingBindingEntry(nameKey);
      Object lock =
    cache.getBindingLock((entry != null) ? entry.key : LAST);
      /* Reserve space for last entry, and requested or next name */
      Cache.Reservation reserve = cache.getReservation(2);
      try {
    /*
     * We're locking the key associated with the entry only after
     * obtaining the entry, because we don't know the key in
     * advance.  That means a concurrent thread might have modified
     * the entry or inserted a new one in the interim, so check and
     * retry in that case.
     */
    synchronized (lock) {
        if (logger.isLoggable(FINEST)) {
      logger.log(FINEST,
           "getBindingInternal txn:" + txn +
           ", name:" + name + " found entry:" + entry);
        }
        if (entry == null) {
      /* No next entry -- create last entry */
      entry = context.createLastBindingEntry(reserve);
      if (entry == null) {
          /* Last entry already present -- try again */
          continue;
      } else {
          /* Fall through to call server */
      }
        } else if (!entry.awaitReadable(lock, stop)) {
      /* The entry is not in the cache -- try again */
      continue;
        } else if (nameKey.equals(entry.key)) {
      /* Name is bound */
      context.noteAccess(entry);
      result = new BindingValue(entry.getValue(), null);
      break;
        } else if (!assureNextEntry(entry, nameKey, true, lock,
            stop))
        {
      /* Entry is no longer for next name -- try again */
      continue;
        } else if (entry.getKnownUnbound(nameKey)) {
      /* Name is unbound */
      context.noteAccess(entry);
      result =
          new BindingValue(-1, entry.key.getNameAllowLast());
      break;
        } else {
      /* Fall through to call server */
        }
        /* Get information from server and try again */
 
View Full Code Here

  Transaction txn, String name, long oid)
    {
  TxnContext context = contextMap.join(txn);
  long stop = context.getStopTime();
  BindingKey nameKey = BindingKey.get(name);
  BindingValue result;
  for (int i = 0; true; i++) {
      if (i >= MAX_CACHE_RETRIES) {
    throw new ResourceUnavailableException("Too many retries");
      }
      /* Find cache entry for name or next higher name */
      BindingCacheEntry entry = cache.getCeilingBindingEntry(nameKey);
      final BindingKey entryKey = (entry != null) ? entry.key : LAST;
      final Object lock = cache.getBindingLock(entryKey);
      /* Reserve space for last entry, and requested or next name */
      Cache.Reservation reserve = cache.getReservation(2);
      try {
    synchronized (lock) {
        if (logger.isLoggable(FINEST)) {
      logger.log(FINEST,
           "setBindingInternal txn:" + txn +
           ", name:" + name + " found entry:" + entry);
        }
        if (entry == null) {
      /* No next entry -- create last entry */
      entry = context.createLastBindingEntry(reserve);
      if (entry == null) {
          /* Last entry already present -- try again */
          continue;
      } else {
          /* Get information from server and try again */
          entry.setPendingPrevious();
          scheduleFetch(
        new GetBindingForUpdateRunnable(
            context, nameKey, entry.key, reserve));
          continue;
      }
        } else if (nameKey.equals(entryKey)) {
      /* Found entry for name */
      if (!setBindingInternalFound(context, lock, entry)) {
          /* Entry is not in cache -- try again */
          continue;
      } else {
          /* Entry is writable */
          context.noteModifiedBinding(entry, oid);
          result = new BindingValue(1, null);
          break;
      }
        } else if (!assureNextEntry(entry, nameKey, true, lock,
            stop))
        {
      /* Entry is no longer for next name -- try again */
      continue;
        } else if (entry.getKnownUnbound(nameKey)) {
      /* Name is unbound */
      if (!setBindingInternalUnbound(
        context, lock, entry, nameKey))
      {
          /*
           * Things changed while trying to get writable next
           * entry -- try again
           */
          continue;
      } else {
          /*
           * Next entry is writable and name is still known
           * to be unbound -- fall through to create entry
           * for the new binding
           */
          context.noteAccess(entry);
      }
        } else {
      /* Get information from server and try again */
      entry.setPendingPrevious();
      context.noteAccess(entry);
      scheduleFetch(
          new GetBindingForUpdateRunnable(
        context, nameKey, entry.key, reserve));
      continue;
        }
    }
      } finally {
    reserve.done();
      }
      /* Get access coordinator lock for the next entry */
      reportNameAccess(txnProxy.getCurrentTransaction(),
           entryKey.getNameAllowLast(), WRITE);
      /* Verify the next entry and mark it pending previous */
      BindingKey entryPreviousKey;
      boolean entryPreviousKeyUnbound;
      synchronized (lock) {
    entry = cache.getBindingEntry(entryKey);
    if (entry == null ||
        !assureNextEntry(entry, nameKey, true, lock, stop))
    {
        /* Next entry changed -- try again */
        continue;
    }
    entry.setPendingPrevious();
    entryPreviousKey = entry.getPreviousKey();
    entryPreviousKeyUnbound = entry.isPreviousKeyUnbound();
      }
      /* Create a new entry for the requested name */
      reserve = cache.getReservation(1);
      try {
    synchronized (cache.getBindingLock(nameKey)) {
        BindingCacheEntry nameEntry =
      context.createNewBindingEntry(nameKey, oid, reserve);
        if (entryPreviousKey != null &&
      entryPreviousKey.compareTo(nameKey) < 0)
        {
      nameEntry.setPreviousKey(
          entryPreviousKey, entryPreviousKeyUnbound);
        }
    }
      } finally {
    reserve.done();
      }
      /* Update the next entry */
      synchronized (lock) {
    entry = cache.getBindingEntry(entryKey);
    assert entry != null : "No entry for " + entryKey;
    /*
     * It's important that we clear the pending previous field on
     * the entry after setting it above.  Currently, none of the
     * intervening calls can fail, but need to make certain this
     * stays true, or else put unwind logic in place.
     * -tjb@sun.com (12/14/2009)
     */
    entry.setNotPendingPrevious(lock);
    context.updatePreviousKey(entry, nameKey, BOUND);
      }
      /* Name was unbound */
      result = new BindingValue(-1, entryKey.getNameAllowLast());
      break;
  }
  maybeCheckBindings(CheckBindingsType.OPERATION);
  return result;
    }
View Full Code Here

  Transaction txn, String name)
    {
  TxnContext context = contextMap.join(txn);
  long stop = context.getStopTime();
  BindingKey nameKey = BindingKey.get(name);
  BindingValue result;
  for (int i = 0; true; i++) {
      if (i >= MAX_CACHE_RETRIES) {
    throw new ResourceUnavailableException("Too many retries");
      }
      /* Find cache entry for name or next higher name */
      BindingCacheEntry entry = cache.getCeilingBindingEntry(nameKey);
      Object lock =
    cache.getBindingLock((entry != null) ? entry.key : LAST);
      boolean nameWritable;
      /* Reserve space for last entry, requested name, and next name */
      Cache.Reservation reserve = cache.getReservation(3);
      try {
    synchronized (lock) {
        if (logger.isLoggable(FINEST)) {
      logger.log(FINEST,
           "removeBindingInternal txn:" + txn +
           ", name:" + name + " found entry:" + entry);
        }
        if (entry == null) {
      /* No next entry -- create last entry */
      entry = context.createLastBindingEntry(reserve);
      if (entry == null) {
          /* Last entry already present -- try again */
          continue;
      } else {
          /* Get information from server and try again */
          entry.setPendingPrevious();
          scheduleFetch(
        new GetBindingForRemoveRunnable(
            context, nameKey, entry.key, reserve));
          continue;
      }
        } else if (nameKey.equals(entry.key)) {
      /* Found entry for name */
      if (!removeBindingInternalFound(entry, lock, stop)) {
          /* Entry is not in cache -- try again */
          continue;
      } else {
          /* Entry is in cache */
          nameWritable = entry.getWritable();
          context.noteAccess(entry);
          /* Fall through to work on next entry */
      }
        } else if (!assureNextEntry(entry, nameKey, true, lock,
            stop))
        {
      /* Entry is no longer for next name -- try again */
      continue;
        } else if (entry.getKnownUnbound(nameKey)) {
      /* Name is unbound */
      context.noteAccess(entry);
      result =
          new BindingValue(-1, entry.key.getNameAllowLast());
      break;
        } else {
      /* Get information from the server and try again */
      entry.setPendingPrevious();
      context.noteAccess(entry);
 
View Full Code Here

TOP

Related Classes of com.sun.sgs.impl.service.data.store.BindingValue

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.