Service for tracking operations changes
@class Service for tracking operations changes
@name orion.progress.ProgressService
@param {orion.serviceregistry.ServiceRegistry} serviceRegistry
@param {orion.operationsclient.OperationsClient} operationsClient
160122
function ProgressService(serviceRegistry, operationsClient, commandRegistry, progressMonitorClass, preferenceService){
		this._serviceRegistry = serviceRegistry;
		this._serviceRegistration = serviceRegistry.registerService("orion.page.progress", this); //$NON-NLS-0$ 
		this._commandRegistry = commandRegistry;
		this._operationsClient = operationsClient;
		this._operations = {};
		this._operationDeferrds = {};
		this._operationsIndex = 0;
		this._lastOperation = null;
		this._lastIconClass = null;
		this._progressMonitorClass = progressMonitorClass;
		this._preferenceService = preferenceService;
	}
620630
function serviceCall(req, res, next) {
        Q(pushService.registerPushDevice(req.body)).then(res.json.bind(res), next).done();
    }
1270808
@Override
	public void injectServices(ServiceRegistryImplementor serviceRegistry) {
		if ( gridDialect instanceof ServiceRegistryAwareService ) {
			( (ServiceRegistryAwareService) gridDialect ).injectServices( serviceRegistry );
		}
	}
271992
def display_progress(cls, operations):
        
        start_crea = datetime.utcnow()

        # count number of operations, 3 steps per operation
        if not isinstance(operations, (list, tuple)):
            operations = [operations]
        count_operations = len(operations) * 3
        updating_done = False
        while not updating_done:
            op_score = 0
            for oper in operations:
                op_ret = cls.call('operation.info', oper['id'])
                op_step = op_ret['step']
                if op_step in cls._op_scores:
                    op_score += cls._op_scores[op_step]
                else:
                    cls.echo('')
                    msg = 'step %s unknown, exiting' % op_step
                    if op_step == 'ERROR':
                        msg = ('An error has occured during operation '
                               'processing: %s' % op_ret['last_error'])
                    elif op_step == 'SUPPORT':
                        msg = ('An error has occured during operation '
                               'processing, you must contact Gandi support.')
                    cls.echo(msg)
                    sys.exit(1)

            cls.update_progress(float(op_score) / count_operations,
                                start_crea)

            if op_score == count_operations:
                updating_done = True

            time.sleep(cls._poll_freq)

        cls.echo('\r')
579027
function(progressMeter, traces) {
      if (this.importing_)
        throw new Error('Already importing.');
      this.importing_ = true;

      // Just some simple setup. It is useful to have a no-op first
      // task so that we can set up the lastTask = lastTask.after()
      // pattern that follows.
      var importTask = new tr.b.Task(function prepareImport() {
        progressMeter.update('I will now import your traces for you...');
      }, this);
      var lastTask = importTask;

      var importers = [];

      lastTask = lastTask.after(function createImports() {
        // Copy the traces array, we may mutate it.
        traces = traces.slice(0);
        progressMeter.update('Creating importers...');
        // Figure out which importers to use.
        for (var i = 0; i < traces.length; ++i)
          importers.push(this.createImporter_(traces[i]));

        // Some traces have other traces inside them. Before doing the full
        // import, ask the importer if it has any subtraces, and if so, create
        // importers for them, also.
        for (var i = 0; i < importers.length; i++) {
          var subtraces = importers[i].extractSubtraces();
          for (var j = 0; j < subtraces.length; j++) {
            try {
              traces.push(subtraces[j]);
              importers.push(this.createImporter_(subtraces[j]));
            } catch (error) {
              // TODO(kphanee): Log the subtrace file which has failed.
              console.warn(error.name + ': ' + error.message);
              continue;
            }
          }
        }

        if (traces.length && !this.hasEventDataDecoder_(importers)) {
          throw new Error(
              'Could not find an importer for the provided eventData.');
        }

        // Sort them on priority. This ensures importing happens in a
        // predictable order, e.g. ftrace_importer before
        // trace_event_importer.
        importers.sort(function(x, y) {
          return x.importPriority - y.importPriority;
        });
      }, this);

      // Run the import.
      lastTask = lastTask.after(function runImport(task) {
        importers.forEach(function(importer, index) {
          task.subTask(function runImportEventsOnOneImporter() {
            progressMeter.update(
                'Importing ' + (index + 1) + ' of ' + importers.length);
            importer.importEvents();
          }, this);
        }, this);
      }, this);

      // Run the cusomizeModelCallback if needed.
      if (this.importOptions_.customizeModelCallback) {
        lastTask = lastTask.after(function runCustomizeCallbacks(task) {
          this.importOptions_.customizeModelCallback(this.model_);
        }, this);
      }

      // Import sample data.
      lastTask = lastTask.after(function(task) {
        importers.forEach(function importSampleData(importer, index) {
          progressMeter.update(
              'Importing sample data ' + (index + 1) + '/' + importers.length);
          importer.importSampleData();
        }, this);
      }, this);

      // Autoclose open slices and create subSlices.
      lastTask = lastTask.after(function runAutoclosers() {
        progressMeter.update('Autoclosing open slices...');
        this.model_.autoCloseOpenSlices();
        this.model_.createSubSlices();
      }, this);

      // Finalize import.
      lastTask = lastTask.after(function finalizeImport(task) {
        importers.forEach(function(importer, index) {
          progressMeter.update(
              'Finalizing import ' + (index + 1) + '/' + importers.length);
          importer.finalizeImport();
        }, this);
      }, this);

      // Run preinit.
      lastTask = lastTask.after(function runPreinits() {
        progressMeter.update('Initializing objects (step 1/2)...');
        this.model_.preInitializeObjects();
      }, this);

      // Prune empty containers.
      if (this.importOptions_.pruneEmptyContainers) {
        lastTask = lastTask.after(function runPruneEmptyContainers() {
          progressMeter.update('Pruning empty containers...');
          this.model_.pruneEmptyContainers();
        }, this);
      }

      // Merge kernel and userland slices on each thread.
      lastTask = lastTask.after(function runMergeKernelWithuserland() {
        progressMeter.update('Merging kernel with userland...');
        this.model_.mergeKernelWithUserland();
      }, this);

      // Create auditors
      var auditors = [];
      lastTask = lastTask.after(function createAuditorsAndRunAnnotate() {
        progressMeter.update('Adding arbitrary data to model...');
        auditors = this.importOptions_.auditorConstructors.map(
          function(auditorConstructor) {
            return new auditorConstructor(this.model_);
          }, this);
        auditors.forEach(function(auditor) {
          auditor.runAnnotate();
          auditor.installUserFriendlyCategoryDriverIfNeeded();
        });
      }, this);

      lastTask = lastTask.after(function computeWorldBounds() {
        progressMeter.update('Computing final world bounds...');
        this.model_.computeWorldBounds(this.importOptions_.shiftWorldToZero);
      }, this);

      // Build the flow event interval tree.
      lastTask = lastTask.after(function buildFlowEventIntervalTree() {
        progressMeter.update('Building flow event map...');
        this.model_.buildFlowEventIntervalTree();
      }, this);

      // Join refs.
      lastTask = lastTask.after(function joinRefs() {
        progressMeter.update('Joining object refs...');
        for (var i = 0; i < importers.length; i++)
          importers[i].joinRefs();
      }, this);

      // Delete any undeleted objects.
      lastTask = lastTask.after(function cleanupUndeletedObjects() {
        progressMeter.update('Cleaning up undeleted objects...');
        this.model_.cleanupUndeletedObjects();
      }, this);

      // Sort global and process memory dumps.
      lastTask = lastTask.after(function sortMemoryDumps() {
        progressMeter.update('Sorting memory dumps...');
        this.model_.sortMemoryDumps();
      }, this);

      // Calculate memory dump graph attributes.
      lastTask = lastTask.after(function calculateMemoryGraphAttributes() {
        progressMeter.update('Calculating memory dump graph attributes...');
        this.model_.calculateMemoryGraphAttributes();
      }, this);

      // Run initializers.
      lastTask = lastTask.after(function initializeObjects() {
        progressMeter.update('Initializing objects (step 2/2)...');
        this.model_.initializeObjects();
      }, this);

      // Build event indices mapping from an event id to all flow events.
      lastTask = lastTask.after(function buildEventIndices() {
        progressMeter.update('Building event indices...');
        this.model_.buildEventIndices();
      }, this);

      // Run audits.
      lastTask = lastTask.after(function runAudits() {
        progressMeter.update('Running auditors...');
        auditors.forEach(function(auditor) {
          auditor.runAudit();
        });
      }, this);

      lastTask = lastTask.after(function sortInteractionRecords() {
        progressMeter.update('Updating interaction records...');
        this.model_.sortInteractionRecords();
      }, this);

      lastTask = lastTask.after(function sortAlerts() {
        progressMeter.update('Updating alerts...');
        this.model_.sortAlerts();
      }, this);

      lastTask = lastTask.after(function lastUpdateBounds() {
        progressMeter.update('Update bounds...');
        this.model_.updateBounds();
      }, this);

      lastTask = lastTask.after(function addModelWarnings() {
        progressMeter.update('Looking for warnings...');
        // Log an import warning if the clock is low resolution.
        if (!this.model_.isTimeHighResolution) {
          this.model_.importWarning({
            type: 'low_resolution_timer',
            message: 'Trace time is low resolution, trace may be unusable.',
            showToUser: true
          });
        }
      }, this);

      // Cleanup.
      lastTask.after(function() {
        this.importing_ = false;
      }, this);
      return importTask;
    }
692334
function process(services) {
            if (services == null || (typeof services === "undefined" ? "undefined" : _typeof(services)) !== "object") {
                throw new Error("Service definitions should be an object, a function returning an object (or a !!promise resolving to an object!!)");
            }
            var index = 0;
            var next = Object.keys(services)[index];
            return this.processKey(index, next, services).then(function () {
                return this;
            }.bind(this));
        }
703900
public void trackTask(final ServiceTaskBase<?> task) {

        LOGGER.trace("track a Task");

        this.serviceTasks.add(task);

        task.setOnCancelled(this.workerHandler);
        task.setOnSucceeded(this.workerHandler);
        task.setOnFailed(this.workerHandler);
    }
927194
public void registerOngoingOperation(
			final K operationKey,
			final CompletableFuture<R> operationResultFuture) {
		final ResultAccessTracker<R> inProgress = ResultAccessTracker.inProgress();
		registeredOperationTriggers.put(operationKey, inProgress);
		operationResultFuture.whenComplete((result, error) -> {
			if (error == null) {
				completedOperations.put(operationKey, inProgress.finishOperation(Either.Right(result)));
			} else {
				completedOperations.put(operationKey, inProgress.finishOperation(Either.Left(error)));
			}
			registeredOperationTriggers.remove(operationKey);
		});
	}
609842
function onServicesChanged(changes,removed) {
  var self = this;
  
  self.emit('servicesChanged',changes,removed);
  var numNew = 0;
  for(var key in changes) {
    if(Object.keys(changes[key]).length > 0) { // not empty
      numNew++;
    }
  }
  //debug("ServicesChanged: added: "+numNew+" removed: "+Object.keys(removed).length);
  // Future: emit per removed network a networkRemoved event
  // Future: emit per added network a networkAdded event
  this.iface.getServices(function(err,services) {
    self._setServices.call(self,Parser.parseServices(services),false);
    updateCurrentService.call(self); 
  });
}
829401
private void applyQuery(long timestamp, RaftSession session, PrimitiveOperation operation, CompletableFuture<OperationResult> future) {
    // If the service has been deleted then throw an unknown service exception.
    if (deleted) {
      log.warn("Service {} has been deleted by another process", serviceName);
      future.completeExceptionally(new RaftException.UnknownService("Service " + serviceName + " has been deleted"));
      return;
    }

    // If the session is not open, fail the request.
    if (!session.getState().active()) {
      log.warn("Inactive session: " + session.sessionId());
      future.completeExceptionally(new RaftException.UnknownSession("Unknown session: " + session.sessionId()));
      return;
    }

    // Set the current operation type to QUERY to prevent events from being sent to clients.
    setOperation(OperationType.QUERY);

    Commit<byte[]> commit = new DefaultCommit<>(currentIndex, operation.id(), operation.value(), session, timestamp);

    long eventIndex = session.getEventIndex();

    OperationResult result;
    try {
      currentSession = session;
      result = OperationResult.succeeded(currentIndex, eventIndex, service.apply(commit));
    } catch (Exception e) {
      result = OperationResult.failed(currentIndex, eventIndex, e);
    } finally {
      currentSession = null;
    }
    future.complete(result);
  }
226089
private void updateSortedServices() {
    List<T> copiedList = new ArrayList<T>(serviceMap.values());
    sortedServices = Collections.unmodifiableList(copiedList);
    if (changeListener != null) {
      changeListener.changed();
    }
  }
260067
function(callback) {
      
      var serviceDefs = this._smd.services;
      
      // Generate the methods to this object
		for(var serviceName in serviceDefs){
		   if( serviceDefs.hasOwnProperty(serviceName) ) {
		      
		      // Get the object that will contain the method.
		      // handles "namespaced" services by breaking apart by '.'
			   var current = this;
			   var pieces = serviceName.split("."); 
			   for(var i=0; i< pieces.length-1; i++){
				   current = current[pieces[i]] || (current[pieces[i]] = {});
			   }
			   
			   current[pieces[pieces.length-1]] =	this._generateService(serviceName, serviceDefs[serviceName]);
		   }
		}
		
		// call the success handler
		if(lang.isObject(callback) && lang.isFunction(callback.success)) {
		   callback.success.call(callback.scope || this);
		}
		
   }
1012967
private void bindProgressProperty(final ServiceTaskBase<?> task, final DoubleProperty progressProperty) {

        // Perform this binding into the JAT to respect widget and task API
        JRebirth.runIntoJAT("Bind Progress Property to " + task.getServiceHandlerName(),
                            () -> {
                                // Avoid the progress bar to display 100% at start up
                                task.updateProgress(0, 0);
                                // Bind the progress bar
                                progressProperty.bind(task.workDoneProperty().divide(task.totalWorkProperty()));
                            });

    }
1225789
protected void updateBoundServiceSensor(String serviceId){
        if(serviceIsBoundToCloudApplication(serviceId)){
            List<String> currentBoundServices = getEntity()
                    .getAttribute(CloudFoundryWebApp.BOUND_SERVICES);
            currentBoundServices.add(serviceId);
            getEntity().setAttribute(CloudFoundryWebApp.BOUND_SERVICES, currentBoundServices);
        }
    }
1349324
function(object, data) {
            if (arguments.length < 2)
                data = observed.get(object);

            /** @type {Notifier} */
            return data && data.notifier || {
                /**
                 * @method notify
                 * @see http://arv.github.io/ecmascript-object-observe/#notifierprototype._notify
                 * @memberof Notifier
                 * @param {ChangeRecord} changeRecord
                 */
                notify: function(changeRecord) {
                    changeRecord.type; // Just to check the property is there...

                    // If there's no data, the object has been unobserved
                    var data = observed.get(object);
                    if (data) {
                        var recordCopy = { object: object }, prop;
                        for (prop in changeRecord)
                            if (prop !== "object")
                                recordCopy[prop] = changeRecord[prop];
                        addChangeRecord(object, data, recordCopy);
                    }
                },

                /**
                 * @method performChange
                 * @see http://arv.github.io/ecmascript-object-observe/#notifierprototype_.performchange
                 * @memberof Notifier
                 * @param {String} changeType
                 * @param {Performer} func     The task performer
                 * @param {*} [thisObj]        Used to set `this` when calling func
                 */
                performChange: function(changeType, func/*, thisObj*/) {
                    if (typeof changeType !== "string")
                        throw new TypeError("Invalid non-string changeType");

                    if (typeof func !== "function")
                        throw new TypeError("Cannot perform non-function");

                    // If there's no data, the object has been unobserved
                    var data = observed.get(object),
                        prop, changeRecord,
                        result = func.call(arguments[2]);

                    data && performPropertyChecks(data, object, changeType);

                    // If there's no data, the object has been unobserved
                    if (data && result && typeof result === "object") {
                        changeRecord = { object: object, type: changeType };
                        for (prop in result)
                            if (prop !== "object" && prop !== "type")
                                changeRecord[prop] = result[prop];
                        addChangeRecord(object, data, changeRecord);
                    }
                }
            };
        }
544216
function uServicesManager(){

 client.publish('uServicesChannel', 'UPDATE');

 listenClient.on('message', function(channel, message) {

  client.get('uServices', function(err, reply) {
   if (reply !== null) {
    uServices = JSON.parse(reply);
   }
  });
 });

 listenClient.on("error", function (err) {
  console.log("Redis listen "+ err);
  listenClient.quit();
 });

 listenClient.subscribe('uServicesChannel');
}
548120
def service_post_save(instance, *args, **kwargs):
    

    # check service
    if instance.is_monitored and settings.REGISTRY_SKIP_CELERY:
        check_service(instance.id)
    elif instance.is_monitored:
        check_service.delay(instance.id)