Returns the number of active instances of the given template name

@param service
@param templateName

@return
774555
public int countActiveInstances(ServiceManagerResourceRestService service, String templateName)
	{
		List<ResourceInstanceDTO> instances = activeInstances(service, templateName);

		return instances.size();
	}
1292529
static Set<String> serviceNames(Service<HttpRequest, HttpResponse> service) {
        if (thriftServiceClass == null || entriesMethod == null || interfacesMethod == null) {
            return ImmutableSet.of();
        }
        return service.as(thriftServiceClass)
                      .map(s -> {
                          @SuppressWarnings("unchecked")
                          final Map<String, ?> entries = (Map<String, ?>) invokeMethod(entriesMethod, s);
                          assert entries != null;
                          return toServiceName(entries.values());
                      })
                      .orElse(ImmutableSet.of());
    }
896331
public List<ModelServiceInstance> getUPModelInstances(String serviceName){
        List<ModelServiceInstance> list = new ArrayList<ModelServiceInstance>();
        for(ModelServiceInstance instance : getModelInstances(serviceName)){
            if(instance.getStatus().equals(OperationalStatus.UP)) {
                list.add(instance);
            }
        }
        return list;
    }
818916
public static <T> Middleware<SyncHandler<Response<T>>, AsyncHandler<Response<ByteString>>> htmlSerializeResponseSync(
      final String templateName) {
    Middleware<SyncHandler<Response<T>>, AsyncHandler<Response<T>>> syncToAsync = Middleware::syncToAsync;
    return syncToAsync.and(htmlSerializeResponse(templateName));
  }
551749
public int getTemplatesSize() {
        int length = 0;
        if (!this.disableTemplatesSupport) {
            try {
                rwLock.readLock().lock();
                length = template_cache.size();
            } finally {
                rwLock.readLock().unlock();
            }
            if (length < 0) {
                length = 0;
            }
        }
        return length;
    }
283547
public List<ModelServiceInstance> getAllInstances(){
        HttpResponse result = invoker.invoke("/service" , null, HttpMethod.GET);

        if (result.getHttpCode() != HTTP_OK) {
           throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR,
                    "HTTP Code is not OK, code=%s", result.getHttpCode());
        }

        List<ModelServiceInstance> allInstances = _deserialize(result.getRetBody(), new TypeReference<List<ModelServiceInstance>>(){});
        return allInstances;
    }
1150886
public static boolean checkForRunningService(Context ctx, String serviceClassName) {
        ActivityManager manager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE);
        for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
            if (serviceClassName.equals(service.service.getClassName())) {
                return true;
            }
        }
        return false;
    }
588366
public ThymeLeafTemplateImplementation getTemplateByResourceName(String resourceName) {
        Collection<ThymeLeafTemplateImplementation> list = registrations.keySet();
        for (ThymeLeafTemplateImplementation template : list) {
            if (template.fullName().endsWith(resourceName)
                    || template.fullName().endsWith(resourceName + "." + extension())) {
                return template;
            }
            if (template.name().equals(resourceName)) {
                return template;
            }
        }
        return null;
    }
1059526
public DruidNodeDiscovery getForService(String serviceName)
  {
    return serviceDiscoveryMap.computeIfAbsent(
        serviceName,
        service -> {

          Set<NodeType> nodeTypesToWatch = DruidNodeDiscoveryProvider.SERVICE_TO_NODE_TYPES.get(service);
          if (nodeTypesToWatch == null) {
            throw new IAE("Unknown service [%s].", service);
          }
          ServiceDruidNodeDiscovery serviceDiscovery = new ServiceDruidNodeDiscovery(service, nodeTypesToWatch.size());
          DruidNodeDiscovery.Listener filteringGatheringUpstreamListener =
              serviceDiscovery.filteringUpstreamListener();
          for (NodeType nodeType : nodeTypesToWatch) {
            getForNodeType(nodeType).registerListener(filteringGatheringUpstreamListener);
          }
          return serviceDiscovery;
        }
    );
  }
457409
public static function count_records_for_template($templateid, $status) {
        $filters = array('templateid' => $templateid);
        if ($status > 0) {
            $filters['status'] = $status;
        }
        return self::count_records($filters);
    }
1182739
def GetTemplateID(alias,location,name):
		
		if alias is None:  alias = clc.v1.Account.GetAlias()
		if location is None:  location = clc.v1.Account.GetLocation()

		r = Server.GetTemplates(alias,location)
		for row in r:
			if row['Name'].lower() == name.lower():  return(row['OperatingSystem'])
		else:
			if clc.args:  clc.v1.output.Status("ERROR",3,"Template %s not found in account %s datacenter %s" % (name,alias,location))
			raise Exception("Template not found")
388337
@VisibleForTesting
  static ServiceInfo getServiceInfo(String serviceName) {
    return ServiceInfo.newBuilder().setName(serviceName).build();
  }
814151
public static long count_filtered(nitro_service service, String viewname, String filter) throws Exception{
		dnsview_dnspolicy_binding obj = new dnsview_dnspolicy_binding();
		obj.set_viewname(viewname);
		options option = new options();
		option.set_count(true);
		option.set_filter(filter);
		dnsview_dnspolicy_binding[] response = (dnsview_dnspolicy_binding[]) obj.getfiltered(service, option);
		if (response != null) {
			return response[0].__count;
		}
		return 0;
	}
167890
public OvhTemplates installationTemplate_templateName_GET(String templateName) throws IOException {
		String qPath = "/me/installationTemplate/{templateName}";
		StringBuilder sb = path(qPath, templateName);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhTemplates.class);
	}
545281
public ArrayList<String> serviceName_install_compatibleTemplatePartitionSchemes_GET(String serviceName, String templateName) throws IOException {
		String qPath = "/dedicated/server/{serviceName}/install/compatibleTemplatePartitionSchemes";
		StringBuilder sb = path(qPath, serviceName);
		query(sb, "templateName", templateName);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, t1);
	}
601997
private static int countWildcardsOccurrences(String templateMessage, String occurrence) {
        if (templateMessage != null && occurrence != null) {
            final Pattern pattern = Pattern.compile(occurrence);
            final Matcher matcher = pattern.matcher(templateMessage);
            int count = 0;
            while (matcher.find()) {
                count++;
            }
            return count;
        } else {
            return 0;
        }
    }
1325050
public static boolean isTemplateExist(RestClient client, String template) throws IOException {
		Response response = client.performRequest(new Request("HEAD", "/_template/" + template));
		return response.getStatusLine().getStatusCode() == 200;
	}