congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ClusterService
Code IndexAdd Tabnine to your IDE (free)

How to use
ClusterService
in
me.hao0.antares.store.service

Best Java code snippets using me.hao0.antares.store.service.ClusterService (Showing top 5 results out of 315)

origin: ihaolin/antares

  @RequestMapping(value = "/clients", method = RequestMethod.GET)
  public JsonResponse clients(@RequestParam("appId") Long appId){

    Response<List<ClientInfo>> clientsResp = clusterService.listClients(appId);
    if (!clientsResp.isSuccess()){
      Logs.error("failed to list clients of app(id={}), cause: {}", appId, clientsResp.getErr());
      return JsonResponse.notOk(messages.get("clients.list.failed"));
    }

    return JsonResponse.ok(clientsResp.getData());
  }
}
origin: ihaolin/antares

@RequestMapping(value = "/servers", method = RequestMethod.GET)
public JsonResponse servers(){
  Response<List<ServerInfo>> serversResp = clusterService.listServers();
  if (!serversResp.isSuccess()){
    Logs.error("failed to list servers, cause: {}", serversResp.getErr());
    return JsonResponse.notOk(messages.get("servers.list.failed"));
  }
  return JsonResponse.ok(serversResp.getData());
}
origin: ihaolin/antares

@Override
public Response<Boolean> scheduleJobIfPossible(Long jobId) {
  try {
    String scheduleServer = jobServerDao.findServerByJobId(jobId);
    if (!Strings.isNullOrEmpty(scheduleServer)){
      // re scheduling
      reloadJob(jobId);
      return Response.ok(true);
    }
    // get current server list
    Response<List<String>> listResp = clusterService.listSimpleServers();
    if (!listResp.isSuccess()){
      Logs.error("failed to list servers when schedule job(id={}) possible, cause: {}, but ignore",
          jobId, listResp.getErr());
      return Response.ok(true);
    }
    List<String> servers = listResp.getData();
    if (CollectionUtil.isNullOrEmpty(servers)){
      // no available server, don't need schedule
      Logs.warn("There are no available server when schedule job(id={}) possible, but ignore.", jobId);
      return Response.ok(true);
    }
    return scheduleJob(jobId);
  } catch (Exception e) {
    Logs.error("failed to schedule job if possible(jobId={})", jobId);
    return Response.notOk("job.schedule.failed");
  }
}
origin: ihaolin/antares

@Override
public Response<Boolean> scheduleJob(Long jobId) {
  try {
    // get current server list
    Response<List<String>> listResp = clusterService.listSimpleServers();
    if (!listResp.isSuccess()){
      return Response.notOk(listResp.getErr());
    }
    List<String> servers = listResp.getData();
    if (CollectionUtil.isNullOrEmpty(servers)){
      // no available server, don't need schedule
      Logs.warn("There are no available servers when schedule job(id={}).", jobId);
      return Response.notOk("server.no.available");
    }
    String targetServer = balancer.balance(servers);
    return Response.ok(doScheduleJob(jobId, targetServer));
  } catch (Exception e) {
    Logs.error("failed to schedule job(jobId={})", jobId);
    return Response.notOk("job.schedule.failed");
  }
}
origin: ihaolin/antares

@Override
public Response<List<JobAssignDto>> listJobAssigns(Long jobId) {
  try {
    Response<JobDetail> jobDetailResp = findJobDetailById(jobId);
    if (!jobDetailResp.isSuccess()){
      return Response.notOk(jobDetailResp.getErr());
    }
    JobDetail jobDetail = jobDetailResp.getData();
    // get all alive clients
    Response<List<ClientInfo>> clientInfosResp = clusterService.listClients(jobDetail.getApp().getId());
    if (!clientInfosResp.isSuccess()){
      return Response.notOk(clientInfosResp.getErr());
    }
    List<ClientInfo> clientInfos = clientInfosResp.getData();
    if (CollectionUtil.isNullOrEmpty(clientInfos)){
      return Response.ok(Collections.<JobAssignDto>emptyList());
    }
    Set<String> assigns = jobAssignDao.listAssigns(jobId);
    List<JobAssignDto> jobAssignDtos = renderJobAssignDtos(clientInfos, assigns);
    return Response.ok(jobAssignDtos);
  } catch (Exception e){
    Logs.error("failed to paging the job assigns(jobId={}), cause: {}", jobId, Throwables.getStackTraceAsString(e));
    return Response.notOk("job.assign.find.failed");
  }
}
me.hao0.antares.store.serviceClusterService

Javadoc

Author: haolin Email: haolin.h0@gmail.com

Most used methods

  • listClients
    List the clients of the app
  • listServers
    List the cluster's server list
  • listSimpleServers
    List the cluster's server string list

Popular in Java

  • Parsing JSON documents to java classes using gson
  • addToBackStack (FragmentTransaction)
  • compareTo (BigDecimal)
  • notifyDataSetChanged (ArrayAdapter)
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now