com.google.appengine.api.modules.ModulesService Java Examples

The following examples show how to use com.google.appengine.api.modules.ModulesService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DevelopersSharedFilter.java    From HotswapAgentExamples with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void doFilter(ServletRequest servletRequest,
		ServletResponse servletResponse, FilterChain filterChain)
		throws IOException, ServletException {

	ModulesService modulesApi = ModulesServiceFactory.getModulesService();
	String instanceHostname = modulesApi.getCurrentInstanceId() + "."
			+ modulesApi.getCurrentVersion() + "."
			+ modulesApi.getCurrentModule();
	Logger logger = LoggerFactory.getLogger(instanceHostname);
	logger.info(logger.getName());

	logger.info("begin guice filter");
	super.doFilter(servletRequest, servletResponse, filterChain);
	logger.info("end guice filter");

	return;
}
 
Example #2
Source File: StackdriverModule.java    From nomulus with Apache License 2.0 5 votes vote down vote up
@Provides
static MetricWriter provideMetricWriter(
    Monitoring monitoringClient,
    @Config("projectId") String projectId,
    ModulesService modulesService,
    @Config("stackdriverMaxQps") int maxQps,
    @Config("stackdriverMaxPointsPerRequest") int maxPointsPerRequest) {
  // The MonitoredResource for GAE apps is not writable (and missing fields anyway) so we just
  // use the gce_instance resource type instead.
  return new StackdriverWriter(
      monitoringClient,
      projectId,
      new MonitoredResource()
          .setType("gce_instance")
          .setLabels(
              ImmutableMap.of(
                  // The "zone" field MUST be a valid GCE zone, so we fake one.
                  "zone",
                  SPOOFED_GCE_ZONE,
                  // Overload the GCE "instance_id" field with the GAE module name, version and
                  // instance_id.
                  "instance_id",
                  modulesService.getCurrentModule()
                      + ":"
                      + modulesService.getCurrentVersion()
                      + ":"
                      + modulesService.getCurrentInstanceId())),
      maxQps,
      maxPointsPerRequest);
}
 
Example #3
Source File: AppEngineTaskQueue.java    From appengine-pipelines with Apache License 2.0 5 votes vote down vote up
private TaskOptions toTaskOptions(Task task) {
  final QueueSettings queueSettings = task.getQueueSettings();

  TaskOptions taskOptions = TaskOptions.Builder.withUrl(TaskHandler.handleTaskUrl());
  if (queueSettings.getOnBackend() != null) {
    taskOptions.header("Host", BackendServiceFactory.getBackendService().getBackendAddress(
        queueSettings.getOnBackend()));
  } else {

    String versionHostname = RetryHelper.runWithRetries(new Callable<String>() {
      @Override
      public String call() {
        ModulesService service = ModulesServiceFactory.getModulesService();
        String module = queueSettings.getOnModule();
        String version = queueSettings.getModuleVersion();
        if (module == null) {
          module = service.getCurrentModule();
          version = service.getCurrentVersion();
        }
        return service.getVersionHostname(module, version);
      }
    }, RetryParams.getDefaultInstance(), MODULES_EXCEPTION_HANDLER);
    taskOptions.header("Host", versionHostname);
  }

  Long delayInSeconds = queueSettings.getDelayInSeconds();
  if (null != delayInSeconds) {
    taskOptions.countdownMillis(delayInSeconds * 1000L);
    queueSettings.setDelayInSeconds(null);
  }
  addProperties(taskOptions, task.toProperties());
  String taskName = task.getName();
  if (null != taskName) {
    taskOptions.taskName(taskName);
  }
  return taskOptions;
}
 
Example #4
Source File: AppEngineServiceUtilsImpl.java    From nomulus with Apache License 2.0 4 votes vote down vote up
@Inject
public AppEngineServiceUtilsImpl(ModulesService modulesService) {
  this.modulesService = modulesService;
}
 
Example #5
Source File: UtilsModule.java    From nomulus with Apache License 2.0 4 votes vote down vote up
@Provides
@Singleton
static ModulesService provideModulesService() {
  return ModulesServiceFactory.getModulesService();
}