Add tool to check if other requests are still running

This is needed for the Lock.java enhancement where a lock will be implicitly
released if the request owning it dies.

No matter which solution we want for refactoring the Lock itself, we will need this class.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167600314
This commit is contained in:
guyben 2017-09-05 10:50:59 -07:00 committed by jianglai
parent 18a13a09a4
commit fa70bd272a
5 changed files with 164 additions and 10 deletions

View file

@ -20,7 +20,6 @@ import static google.registry.request.RequestParameters.extractRequiredParameter
import com.google.api.services.bigquery.model.TableFieldSchema;
import com.google.appengine.api.taskqueue.Queue;
import com.google.apphosting.api.ApiProxy;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import dagger.Module;
@ -28,6 +27,7 @@ import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import google.registry.request.Parameter;
import google.registry.request.RequestLogId;
import google.registry.util.Clock;
import java.util.UUID;
import javax.inject.Named;
@ -39,8 +39,6 @@ import javax.servlet.http.HttpServletRequest;
@Module
public class WhiteboxModule {
private static final String REQUEST_LOG_ID = "com.google.appengine.runtime.request_log_id";
@Provides
@IntoMap
@StringKey(EppMetric.TABLE_ID)
@ -71,16 +69,10 @@ public class WhiteboxModule {
};
}
@Provides
@Named("requestLogId")
static String provideRequestLogId() {
return ApiProxy.getCurrentEnvironment().getAttributes().get(REQUEST_LOG_ID).toString();
}
/** Provides an EppMetric builder with the request ID and startTimestamp already initialized. */
@Provides
static EppMetric.Builder provideEppMetricBuilder(
@Named("requestLogId") String requestLogId, Clock clock) {
@RequestLogId String requestLogId, Clock clock) {
return EppMetric.builderForRequest(requestLogId, clock);
}