/**
* Copyright 2016 LinkedIn Corp. 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.
*/
package com.github.ambry.tools.perf.rest;
import com.github.ambry.config.Config;
import com.github.ambry.config.Default;
import com.github.ambry.config.VerifiableProperties;
import com.github.ambry.rest.RestMethod;
/**
* Configuration parameters associated with performance tests.
*/
class PerfConfig {
// General
/**
* Size in bytes of the blob that will used for GET/POST.
*/
@Config("perf.blob.size")
@Default("10485760")
public final long perfBlobSize;
/**
* Size in bytes of the user metadata that will used for GET/HEAD/POST.
*/
@Config("perf.user.metadata.size")
@Default("1024")
public final int perfUserMetadataSize;
// PerfNioServer
/**
* Size in bytes of each chunk that will created during POST by the {@link PerfNioServer}.
*/
@Config("perf.nio.server.chunk.size")
@Default("8192")
public final int perfNioServerChunkSize;
/**
* Number of concurrent requests.
*/
@Config("perf.nio.server.concurrency")
@Default("1")
public final int perfNioServerConcurrency;
/**
* {@link RestMethod} desired in the {@link com.github.ambry.rest.RestRequest} generated by {@link PerfNioServer}.
*/
@Config("perf.request.rest.method")
@Default("GET")
public final RestMethod perfRequestRestMethod;
// PerfRouter
/**
* Size in bytes of each chunk that will created during GET by the {@link PerfRouter}.
*/
@Config("perf.router.chunk.size")
@Default("1048576")
public final int perfRouterChunkSize;
public PerfConfig(VerifiableProperties verifiableProperties) {
// General
perfBlobSize = verifiableProperties.getLong("perf.blob.size", 10485760);
perfUserMetadataSize = verifiableProperties.getIntInRange("perf.user.metadata.size", 1024, 0, 81920);
// PerfNioServer
perfNioServerChunkSize = verifiableProperties.getIntInRange("perf.nio.server.chunk.size", 8192, 1, 10485760);
perfNioServerConcurrency =
verifiableProperties.getIntInRange("perf.nio.server.concurrency", 1, 1, Integer.MAX_VALUE);
perfRequestRestMethod = RestMethod.valueOf(
verifiableProperties.getString("perf.request.rest.method", RestMethod.GET.toString()).toUpperCase());
// PerfRouter
perfRouterChunkSize = verifiableProperties.getIntInRange("perf.router.chunk.size", 1048576, 1, 10485760);
}
}