google-nomulus/java/google/registry/loadtest/LoadTestModule.java
Justine Tunney 5012893c1d mv com/google/domain/registry google/registry
This change renames directories in preparation for the great package
rename. The repository is now in a broken state because the code
itself hasn't been updated. However this should ensure that git
correctly preserves history for each file.
2016-05-13 18:55:08 -04:00

118 lines
3.7 KiB
Java

// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.loadtest;
import static com.google.domain.registry.request.RequestParameters.extractOptionalIntParameter;
import static com.google.domain.registry.request.RequestParameters.extractRequiredParameter;
import com.google.domain.registry.request.Parameter;
import dagger.Module;
import dagger.Provides;
import org.joda.time.Minutes;
import javax.servlet.http.HttpServletRequest;
/**
* Dagger module for loadtest package.
*
* @see "com.google.domain.registry.module.backend.ToolsComponent"
*/
@Module
public final class LoadTestModule {
// There's already an @Parameter("clientId") for CreateGroupsAction that's only optional, and we
// want this one to be required, so give it a different name.
@Provides
@Parameter("loadtestClientId")
static String provideClientId(HttpServletRequest req) {
return extractRequiredParameter(req, "clientId");
}
@Provides
@Parameter("delaySeconds")
static int provideDelaySeconds(HttpServletRequest req) {
return extractOptionalIntParameter(req, "delaySeconds")
.or(Minutes.ONE.toStandardSeconds().getSeconds());
}
@Provides
@Parameter("runSeconds")
static int provideRunSeconds(HttpServletRequest req) {
return extractOptionalIntParameter(req, "runSeconds")
.or(Minutes.ONE.toStandardSeconds().getSeconds());
}
@Provides
@Parameter("successfulDomainCreates")
static int provideSuccessfulDomainCreates(HttpServletRequest req) {
return extractOptionalIntParameter(req, "successfulDomainCreates").or(0);
}
@Provides
@Parameter("failedDomainCreates")
static int provideFailedDomainCreates(HttpServletRequest req) {
return extractOptionalIntParameter(req, "failedDomainCreates").or(0);
}
@Provides
@Parameter("domainInfos")
static int provideDomainInfos(HttpServletRequest req) {
return extractOptionalIntParameter(req, "domainInfos").or(0);
}
@Provides
@Parameter("domainChecks")
static int provideDomainChecks(HttpServletRequest req) {
return extractOptionalIntParameter(req, "domainChecks").or(0);
}
@Provides
@Parameter("successfulContactCreates")
static int provideSuccessfulContactCreates(HttpServletRequest req) {
return extractOptionalIntParameter(req, "successfulContactCreates").or(0);
}
@Provides
@Parameter("failedContactCreates")
static int provideFailedContactCreates(HttpServletRequest req) {
return extractOptionalIntParameter(req, "failedContactCreates").or(0);
}
@Provides
@Parameter("contactInfos")
static int provideContactInfos(HttpServletRequest req) {
return extractOptionalIntParameter(req, "contactInfos").or(0);
}
@Provides
@Parameter("successfulHostCreates")
static int provideSuccessfulHostCreates(HttpServletRequest req) {
return extractOptionalIntParameter(req, "successfulHostCreates").or(0);
}
@Provides
@Parameter("failedHostCreates")
static int provideFailedHostCreates(HttpServletRequest req) {
return extractOptionalIntParameter(req, "failedHostCreates").or(0);
}
@Provides
@Parameter("hostInfos")
static int provideHostInfos(HttpServletRequest req) {
return extractOptionalIntParameter(req, "hostInfos").or(0);
}
}