Examples of DataService


Examples of com.sun.sgs.service.DataService

   * also removes the protocol descriptors for the node
   * specified during construction.
   */
  public void run() {
      String sessionServerKey = getClientSessionServerKey(nodeId);
      DataService dataService = getDataService();
      try {
    dataService.removeObject(
        dataService.getServiceBinding(sessionServerKey));
    getProtocolDescriptorsMap().remove(nodeId);
      } catch (NameNotBoundException e) {
    // already removed
    return;
      } catch (ObjectNotFoundException e) {
      }
      dataService.removeServiceBinding(sessionServerKey);
  }
View Full Code Here

Examples of com.sun.sgs.service.DataService

            this.properties = properties;
        }

        /** Starts the application, throwing an exception on failure. */
        public void run() throws Exception {
            DataService dataService =
                Kernel.proxy.getService(DataService.class);
            try {
                // test to see if this name if the listener is already bound...
                dataService.getServiceBinding(StandardProperties.APP_LISTENER);
            } catch (NameNotBoundException nnbe) {
                // ...if it's not, create and then bind the listener
                AppListener listener =
                    (new PropertiesWrapper(properties)).
                    getClassInstanceProperty(StandardProperties.APP_LISTENER,
                                             AppListener.class, new Class[] {});
                if (listener instanceof ManagedObject) {
                    dataService.setServiceBinding(
                            StandardProperties.APP_LISTENER, listener);
                } else {
                    dataService.setServiceBinding(
                            StandardProperties.APP_LISTENER,
                            new ManagedSerializable<AppListener>(listener));
                }

                // since we created the listener, we're the first one to
View Full Code Here

Examples of com.sun.sgs.service.DataService

   
    /** {@inheritDoc} */
    @SuppressWarnings("unchecked")
    public V remove(Object key) {
  checkKey("key", key);
  DataService dataService = BindingKeyedCollectionsImpl.getDataService();
  String bindingName = getBindingName((String) key);
  V value = null;
  try {
      ManagedObject v = dataService.getServiceBinding(bindingName);
      if (v instanceof Wrapper) {
    value = (V) ((Wrapper) v).get();
    dataService.removeObject(v);
      } else {
    value = (V) v;
      }
      dataService.removeServiceBinding(bindingName);
  } catch (NameNotBoundException e) {
  }
  return value;
    }
View Full Code Here

Examples of com.sun.sgs.service.DataService

     * @param  keyPrefix a key prefix
     * @returns  {@code true} if the {@code keyPrefix} corresponds to an
     *    empty map
     */
    private static boolean isEmptyInternal(String keyPrefix) {
  DataService dataService = BindingKeyedCollectionsImpl.getDataService();
  String key = dataService.nextServiceBoundName(keyPrefix);
  return key == null || !key.startsWith(keyPrefix);
    }
View Full Code Here

Examples of com.sun.sgs.service.DataService

    /**
     * Returns {@code true} if a service binding with the specified
     * {@code bindingName} exists.
     */
    private static boolean containsKeyInternal(String bindingName) {
  DataService dataService = BindingKeyedCollectionsImpl.getDataService();
  boolean containsKey = false;
  try {
      dataService.getServiceBinding(bindingName);
      containsKey = true;
  } catch (NameNotBoundException e) {
  } catch (ObjectNotFoundException e) {
      containsKey = true;
  }
View Full Code Here

Examples of com.sun.sgs.service.DataService

     * {@code false}.
     */
    private static boolean removeOverrideInternal(String bindingName) {
  boolean previouslyMapped = containsKeyInternal(bindingName);
  if (previouslyMapped) {
      DataService dataService =
    BindingKeyedCollectionsImpl.getDataService();
      try {
    removeValue(bindingName);
      } catch (ObjectNotFoundException ignore) {
      }
      dataService.removeServiceBinding(bindingName);
  }
  return previouslyMapped;
    }
View Full Code Here

Examples of com.sun.sgs.service.DataService

     * @throws  NameNotBoundException if the service binding does not exist
     * @throws  ObjectNotFoundException if the value associated with the
     *    specified {@code bindingName} has been removed
     */
    private static void removeValue(String bindingName) {
  DataService dataService =
      BindingKeyedCollectionsImpl.getDataService();
  ManagedObject v = dataService.getServiceBinding(bindingName);
  if (v instanceof Wrapper) {
      dataService.removeObject(v);
  }
    }
View Full Code Here

Examples of com.sun.sgs.service.DataService

  this.identity = identity;
  this.deliveries = deliveries;
  this.nodeId = sessionService.getLocalNodeId();
        this.maxMessageLength = maxMessageLength;
  writeBufferCapacity = sessionService.getWriteBufferSize();
  DataService dataService = sessionService.getDataService();
  ManagedReference<ClientSessionImpl> sessionRef =
      dataService.createReference(this);
  id = sessionRef.getId();
  this.wrappedSessionRef =
      dataService.createReference(new ClientSessionWrapper(sessionRef));
  idBytes = id.toByteArray();
  // TBD: these service bindings could be stored in a BindingKeyedMap
  // instead.
  dataService.setServiceBinding(getSessionKey(), this);
  dataService.setServiceBinding(getSessionNodeKey(), this);
  dataService.setServiceBinding(getEventQueueKey(), new EventQueue(this));
  logger.log(Level.FINEST, "Stored session, identity:{0} id:{1}",
       identity, id);
    }
View Full Code Here

Examples of com.sun.sgs.service.DataService

  if (newNodeId != sessionService.getLocalNodeId()) {
      throw new IllegalArgumentException(
    "newNodeId:" + newNodeId + " must match the local node ID:" +
    sessionService.getLocalNodeId());
  }
  DataService dataService = sessionService.getDataService();
  dataService.markForUpdate(this);
  dataService.removeServiceBinding(getSessionNodeKey());
  nodeId = newNodeId;
  // TBD: this could use a BindingKeyedMap.
  dataService.setServiceBinding(getSessionNodeKey(), this);
    }
View Full Code Here

Examples of org.eclipse.egit.github.core.service.DataService

      info("Creating 1 blob");
    if (isDebug())
      debug(MessageFormat.format("Scanned files to include: {0}",
          Arrays.toString(paths)));

    DataService service = new DataService(createClient(host, userName,
        password, oauth2Token, server, settings, session));

    // Write blobs and build tree entries
    List<TreeEntry> entries = new ArrayList<TreeEntry>(paths.length);
    //String prefix = path;
    String prefix = site.getRoot();
    if (prefix == null)
      prefix = "";
    if (prefix.length() > 0 && !prefix.endsWith("/"))
      prefix += "/";

    // Convert separator to forward slash '/'
    if ('\\' == File.separatorChar)
      for (int i = 0; i < paths.length; i++)
        paths[i] = paths[i].replace('\\', '/');

    boolean createNoJekyll = noJekyll;

    for (String path : paths) {
      TreeEntry entry = new TreeEntry();
      entry.setPath(prefix + path);
      // Only create a .nojekyll file if it doesn't already exist
      if (createNoJekyll && NO_JEKYLL_FILE.equals(entry.getPath()))
        createNoJekyll = false;
      entry.setType(TYPE_BLOB);
      entry.setMode(MODE_BLOB);
      entry.setSha(createBlob(service, repository, outputDirectory, path));
      entries.add(entry);
    }

    if (createNoJekyll) {
      TreeEntry entry = new TreeEntry();
      entry.setPath(NO_JEKYLL_FILE);
      entry.setType(TYPE_BLOB);
      entry.setMode(MODE_BLOB);

      if (isDebug())
        debug("Creating empty .nojekyll blob at root of tree");
      if (!dryRun)
        try {
          entry.setSha(service.createBlob(repository, new Blob()
              .setEncoding(ENCODING_BASE64).setContent("")));
        } catch (IOException e) {
          throw new MojoExecutionException(
              "Error creating .nojekyll empty blob: "
                  + getExceptionMessage(e), e);
        }
      entries.add(entry);
    }

    Reference ref = null;
    try {
      ref = service.getReference(repository, branch);
    } catch (RequestException e) {
      if (404 != e.getStatus())
        throw new MojoExecutionException("Error getting reference: "
            + getExceptionMessage(e), e);
    } catch (IOException e) {
      throw new MojoExecutionException("Error getting reference: "
          + getExceptionMessage(e), e);
    }

    if (ref != null && !TYPE_COMMIT.equals(ref.getObject().getType()))
      throw new MojoExecutionException(
          MessageFormat
              .format("Existing ref {0} points to a {1} ({2}) instead of a commmit",
                  ref.getRef(), ref.getObject().getType(),
                  ref.getObject().getSha()));

    // Write tree
    Tree tree;
    try {
      int size = entries.size();
      if (size != 1)
        info(MessageFormat.format(
            "Creating tree with {0} blob entries", size));
      else
        info("Creating tree with 1 blob entry");
      String baseTree = null;
      if (merge && ref != null) {
        Tree currentTree = service.getCommit(repository,
            ref.getObject().getSha()).getTree();
        if (currentTree != null)
          baseTree = currentTree.getSha();
        info(MessageFormat.format("Merging with tree {0}", baseTree));
      }
      if (!dryRun)
        tree = service.createTree(repository, entries, baseTree);
      else
        tree = new Tree();
    } catch (IOException e) {
      throw new MojoExecutionException("Error creating tree: "
          + getExceptionMessage(e), e);
    }

    // Build commit
    Commit commit = new Commit();
    commit.setMessage(message);
    commit.setTree(tree);

    // Set parent commit SHA-1 if reference exists
    if (ref != null)
      commit.setParents(Collections.singletonList(new Commit().setSha(ref
          .getObject().getSha())));

    Commit created;
    try {
      if (!dryRun)
        created = service.createCommit(repository, commit);
      else
        created = new Commit();
      info(MessageFormat.format("Creating commit with SHA-1: {0}",
          created.getSha()));
    } catch (IOException e) {
      throw new MojoExecutionException("Error creating commit: "
          + getExceptionMessage(e), e);
    }

    TypedResource object = new TypedResource();
    object.setType(TYPE_COMMIT).setSha(created.getSha());
    if (ref != null) {
      // Update existing reference
      ref.setObject(object);
      try {
        info(MessageFormat.format(
            "Updating reference {0} from {1} to {2}", branch,
            commit.getParents().get(0).getSha(), created.getSha()));
        if (!dryRun)
          service.editReference(repository, ref, force);
      } catch (IOException e) {
        throw new MojoExecutionException("Error editing reference: "
            + getExceptionMessage(e), e);
      }
    } else {
      // Create new reference
      ref = new Reference().setObject(object).setRef(branch);
      try {
        info(MessageFormat.format(
            "Creating reference {0} starting at commit {1}",
            branch, created.getSha()));
        if (!dryRun)
          service.createReference(repository, ref);
      } catch (IOException e) {
        throw new MojoExecutionException("Error creating reference: "
            + getExceptionMessage(e), e);
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.