Package com.sun.sgs.service

Examples of com.sun.sgs.service.DataService


    @Test
    public void testMarkForUpdate() throws Exception {
  Properties props = getNodeProps();
  props.setProperty("com.sun.sgs.txn.timeout", "10000");
  serverNode = new SgsTestNode("TestDataServicePerformance", null, props);
  final DataService service = serverNode.getDataService();
        TransactionScheduler txnScheduler = serverNode.getSystemRegistry().
            getComponent(TransactionScheduler.class);
        Identity taskOwner = serverNode.getProxy().getCurrentOwner();
        txnScheduler.runTask(new TestAbstractKernelRunnable() {
                public void run() {
                    service.setBinding("counters", new Counters(items));
                }}, taskOwner);
        for (int r = 0; r < repeat; r++) {
            long start = System.currentTimeMillis();
            for (int c = 0; c < count; c++) {
                txnScheduler.runTask(new TestAbstractKernelRunnable() {
                        public void run() throws Exception {
                            Counters counters =
                                (Counters) service.getBinding("counters");
          DataManager dataManager =
        AppContext.getDataManager();
                            for (int i = 0; i < items; i++) {
                                Counter counter = counters.get(i);
        dataManager.markForUpdate(counter);
View Full Code Here


  props.setProperty(DataServiceImplClass + ".detect.modifications",
        String.valueOf(detectMods));
  props.setProperty(DataStoreImplClass + ".flush.to.disk",
        String.valueOf(flush));
  serverNode = new SgsTestNode("TestDataServicePerformance", null, props);
  final DataService service = serverNode.getDataService();
        TransactionScheduler txnScheduler = serverNode.getSystemRegistry().
            getComponent(TransactionScheduler.class);
        Identity taskOwner = serverNode.getProxy().getCurrentOwner();
        txnScheduler.runTask(new TestAbstractKernelRunnable() {
                public void run() {
                    service.setBinding("counters", new Counters(items));
                }}, taskOwner);
        for (int r = 0; r < repeat; r++) {
            long start = System.currentTimeMillis();
            for (int c = 0; c < count; c++) {
                txnScheduler.runTask(new TestAbstractKernelRunnable() {
                        public void run() throws Exception {
                            Counters counters =
                                (Counters) service.getBinding("counters");
                            for (int i = 0; i < items; i++) {
                                Counter counter = counters.get(i);
                                if ( i < modifyItems) {
                                    service.markForUpdate(counter);
                                    counter.next();
                                }
                            }
                        }}, taskOwner);
            }
View Full Code Here

   * also removes the protocol descriptors for the node
   * specified during construction.
   */
  public void run() {
      String sessionServerKey = getClientSessionServerKey(nodeId);
      DataService dataService = getInstance().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

     * within a transaction.
     */
    private static Map<Long, Set<ProtocolDescriptor>>
  getProtocolDescriptorsMap()
    {
  DataService dataService = getInstance().getDataService();
  Map<Long, Set<ProtocolDescriptor>> protocolDescriptorsMap;
  try {
      protocolDescriptorsMap = Objects.uncheckedCast(
    dataService.getServiceBinding(PROTOCOL_DESCRIPTORS_MAP_KEY));
  } catch (NameNotBoundException e) {
      protocolDescriptorsMap =
    new ScalableHashMap<Long, Set<ProtocolDescriptor>>();
      dataService.setServiceBinding(PROTOCOL_DESCRIPTORS_MAP_KEY,
            protocolDescriptorsMap);
  }
  return protocolDescriptorsMap;
    }
View Full Code Here

            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

    {
  if (name == null) {
      throw new NullPointerException("null name");
  }
  this.name = name;
  DataService dataService = getDataService();
  if (listener != null) {
      if (!(listener instanceof Serializable)) {
    throw new IllegalArgumentException("non-serializable listener");
      } else if (!(listener instanceof ManagedObject)) {
    listener = new ManagedSerializableChannelListener(listener);
      }
      this.listenerRef = dataService.createReference(listener);
  } else {
      this.listenerRef = null;
  }
  this.delivery = delivery;
  this.writeBufferCapacity = writeBufferCapacity;
  this.txn = ChannelServiceImpl.getTransaction();
  ManagedReference<ChannelImpl> ref = dataService.createReference(this);
  if (channelWrapper == null) {
      channelWrapper = new ChannelWrapper(ref);
  } else {
      channelWrapper.setChannelRef(ref);
  }
  this.wrappedChannelRef = dataService.createReference(channelWrapper);
  this.channelRefId = ref.getId();
  this.coordNodeId = getLocalNodeId();
  if (logger.isLoggable(Level.FINER)) {
      logger.log(Level.FINER, "Created ChannelImpl:{0}", channelRefId);
  }
  getChannelsMap().putOverride(name, this);
  EventQueue eventQueue = new EventQueue(this);
  eventQueueRef = dataService.createReference(eventQueue);
  getEventQueuesMap(coordNodeId).
      put(channelRefId.toString(), eventQueue);
    }
View Full Code Here

     *
     * 2) Sends out a 'serviceEventQueue' request to the new
     * coordinator to restart this channel's event processing.
     */
    private void reassignCoordinator(long failedCoordNodeId) {
  DataService dataService = getDataService();
  if (coordNodeId != failedCoordNodeId) {
      logger.log(
    Level.SEVERE,
    "attempt to reassign coordinator:{0} for channel:{1} " +
    "that is not the failed node:{2}",
    coordNodeId, failedCoordNodeId, this);
      return;
  }

  /*
   * Assign a new coordinator, and store event queue in new
   * coordinator's event queue map.
   */
  dataService.markForUpdate(this);
  coordNodeId = chooseCoordinatorNode();
  isCoordinatorReassigned = true;
  if (logger.isLoggable(Level.FINER)) {
      logger.log(
    Level.FINER,
View Full Code Here

     * which case the channel's name binding is not removed) and is
     * called when the channel is closed (in which case the channel's
     * name binding is removed).
     */
    private void removeChannel(boolean removeName) {
  DataService dataService = getDataService();
  if (removeName) {
      getChannelsMap().removeOverride(name);
  }
  dataService.removeObject(this);
  if (listenerRef != null) {
      ChannelListener maybeWrappedListener = null;
      try {
    maybeWrappedListener = listenerRef.get();
      } catch (ObjectNotFoundException ignore) {
    // listener already removed
      }
      if (maybeWrappedListener instanceof ManagedSerializable) {
    dataService.removeObject(maybeWrappedListener);
      }
  }
  BindingKeyedMap<EventQueue> eventQueuesMap =
      getEventQueuesMap(coordNodeId);
  eventQueuesMap.removeOverride(channelRefId.toString());
  EventQueue eventQueue = eventQueueRef.get();
  dataService.removeObject(eventQueue);
  if (isReliable()) {
      SavedMessageReaper.scheduleNewTask(channelRefId, true);
  }
    }
View Full Code Here

    }

    /* -- Test constructor -- */

    @Test public void testConstructor() throws Exception {
  DataService dataService = null;
        WatchdogServiceImpl watchdog = null;
        try {
      dataService = createDataService(serviceProps);
            watchdog = new WatchdogServiceImpl(
    serviceProps, systemRegistry, txnProxy, dummyShutdownCtrl)
        } finally {
      if (dataService != null) dataService.shutdown();
            if (watchdog != null) watchdog.shutdown();
        }
    }
View Full Code Here

            public void run() throws Exception {
                checkHealth(watchdogService, Health.GREEN);
            }
        }, taskOwner);

  DataService dataService = createDataService(serviceProps);
  final WatchdogServiceImpl watchdog =
      new WatchdogServiceImpl(serviceProps, systemRegistry, txnProxy,
            dummyShutdownCtrl);
  try {
            txnScheduler.runTask(new TestAbstractKernelRunnable() {
                public void run() throws Exception {
                    checkHealth(watchdogService, Health.GREEN);
                }
            }, taskOwner);

      watchdogService.shutdown();
      // wait for watchdog's renew to fail...
      Thread.sleep(renewTime * 4);

            txnScheduler.runTask(new TestAbstractKernelRunnable() {
                public void run() throws Exception {
                    checkHealth(watchdog, Health.RED);
                }
            }, taskOwner);

  } finally {
      watchdog.shutdown();
      dataService.shutdown();
  }
    }
View Full Code Here

TOP

Related Classes of com.sun.sgs.service.DataService

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.