本文整理汇总了Java中io.hops.metadata.yarn.entity.quota.PriceMultiplicator类的典型用法代码示例。如果您正苦于以下问题:Java PriceMultiplicator类的具体用法?Java PriceMultiplicator怎么用?Java PriceMultiplicator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PriceMultiplicator类属于io.hops.metadata.yarn.entity.quota包,在下文中一共展示了PriceMultiplicator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentMultiplicator
import io.hops.metadata.yarn.entity.quota.PriceMultiplicator; //导入依赖的package包/类
private Map<PriceMultiplicator.MultiplicatorType, PriceMultiplicator> getCurrentMultiplicator()
throws IOException {
LightWeightRequestHandler currentPriceHandler
= new LightWeightRequestHandler(YARNOperationType.TEST) {
@Override
public Object performTask() throws StorageException {
connector.beginTransaction();
connector.readCommitted();
Map<PriceMultiplicator.MultiplicatorType, PriceMultiplicator> currentPrices
= priceMultiplicatorDA.getAll();
connector.commit();
return currentPrices;
}
};
return (Map<PriceMultiplicator.MultiplicatorType, PriceMultiplicator>) currentPriceHandler.
handle();
}
示例2: persistMultiplicators
import io.hops.metadata.yarn.entity.quota.PriceMultiplicator; //导入依赖的package包/类
private void persistMultiplicators() throws IOException {
LightWeightRequestHandler prepareHandler;
prepareHandler = new LightWeightRequestHandler(YARNOperationType.TEST) {
@Override
public Object performTask() throws IOException {
connector.beginTransaction();
connector.writeLock();
for (Map.Entry<PriceMultiplicator.MultiplicatorType, Float> entry : currentMultiplicators.entrySet()) {
priceMultiplicatorDA.add(new PriceMultiplicator(entry.getKey(), entry.getValue()));
}
connector.commit();
LOG.debug("Commited new multiplicator: " + currentMultiplicators + "for VARIABLE");
return null;
}
};
prepareHandler.handle();
}
示例3: recover
import io.hops.metadata.yarn.entity.quota.PriceMultiplicator; //导入依赖的package包/类
/**
* Retrieve tick counter, unfinished containers logs entries and container
* statuses entries. Merge them and then retrieve events that have arrived
* since launching service. Merge events and mark recovery as completed.
*/
public void recover() {
LOG.info("Starting containers logs recovery");
try {
tickCounter = getTickCounter();
activeContainers = getContainersLogs();
//recover current multiplicator
Map<PriceMultiplicator.MultiplicatorType, PriceMultiplicator> currentMultiplicators = getCurrentMultiplicator();
for (PriceMultiplicator.MultiplicatorType type : PriceMultiplicator.MultiplicatorType.values()) {
if (currentMultiplicators.get(type) != null) {
this.currentMultiplicators.put(type, currentMultiplicators.get(type).getValue());
}
}
//Finish to log all the containers for which we currently have logs
//they will restart once they send a new heartbeat
finishLogging();
updateContainersLogs(false);
LOG.info("Finished containers logs recovery");
} catch (Exception ex) {
LOG.warn("Unable to finish containers logs recovery", ex);
}
}
示例4: getCurrentMultiplicator
import io.hops.metadata.yarn.entity.quota.PriceMultiplicator; //导入依赖的package包/类
private Map<PriceMultiplicator.MultiplicatorType, PriceMultiplicator> getCurrentMultiplicator()
throws IOException {
LightWeightRequestHandler currentPriceHandler
= new LightWeightRequestHandler(YARNOperationType.TEST) {
@Override
public Object performTask() throws StorageException {
connector.beginTransaction();
connector.readCommitted();
PriceMultiplicatorDataAccess da
= (PriceMultiplicatorDataAccess) RMStorageFactory.getDataAccess(
PriceMultiplicatorDataAccess.class);
Map<PriceMultiplicator.MultiplicatorType, PriceMultiplicator> currentPrices
= da.getAll();
connector.commit();
return currentPrices;
}
};
return (Map<PriceMultiplicator.MultiplicatorType, PriceMultiplicator>) currentPriceHandler.
handle();
}
示例5: createCheckpoint
import io.hops.metadata.yarn.entity.quota.PriceMultiplicator; //导入依赖的package包/类
/**
* Loop active list and add all found & not completed container statuses to
* update list. This ensures that whole running time is not lost.
*/
private synchronized void createCheckpoint() {
long tick = tickCounter.getValue();
for (ContainerLog log : activeContainers.values()) {
if ((tick - log.getStart()) % checkpointInterval == 0) {
log.setStop(tickCounter.getValue());
if (((tick - log.getStart()) / checkpointInterval) % multiplicatorPeirod == 0) {
float currentMultiplicator;
if (log.getGpuUsed() != 0) {
currentMultiplicator = currentMultiplicators.get(PriceMultiplicator.MultiplicatorType.GPU);
} else {
currentMultiplicator = currentMultiplicators.get(PriceMultiplicator.MultiplicatorType.GENERAL);
}
log.setPrice(currentMultiplicator);
}
updateContainers.put(log.getContainerid(), log);
}
}
}
示例6: getMultiplicator
import io.hops.metadata.yarn.entity.quota.PriceMultiplicator; //导入依赖的package包/类
public YarnPriceMultiplicator getMultiplicator(PriceMultiplicator.MultiplicatorType multiplicatorType) {
try {
TypedQuery<YarnPriceMultiplicator> query = em.
createNamedQuery("YarnPriceMultiplicator.findById", YarnPriceMultiplicator.class).setParameter("id",
multiplicatorType.name());
return query.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
示例7: getMultiplicator
import io.hops.metadata.yarn.entity.quota.PriceMultiplicator; //导入依赖的package包/类
/**
* Gets the yarn price multiplicator from cache if it is not older than
* CACHE_MAX_AGE, from the database otherwise.
*
* @return YarnPriceMultiplicator
*/
public YarnPriceMultiplicator getMultiplicator() {
long timeNow = System.currentTimeMillis();
if (timeNow - lastUpdated > CACHE_MAX_AGE || multiplicator == null) {
lastUpdated = System.currentTimeMillis();
multiplicator = yarnProjectsQuotaFacade.getMultiplicator(PriceMultiplicator.MultiplicatorType.GENERAL);
}
return multiplicator;
}
示例8: serviceInit
import io.hops.metadata.yarn.entity.quota.PriceMultiplicator; //导入依赖的package包/类
@Override
public void serviceInit(Configuration conf) throws Exception {
LOG.info("Initializing price estimation service");
this.conf = conf;
// Initialize config parameters
this.tippingPoints.put(PriceMultiplicator.MultiplicatorType.GENERAL, this.conf.getFloat(
YarnConfiguration.QUOTA_MULTIPLICATOR_THRESHOLD_GENERAL,
YarnConfiguration.DEFAULT_QUOTA_MULTIPLICATOR_THRESHOLD_GENERAL));
this.tippingPoints.put(PriceMultiplicator.MultiplicatorType.GPU, this.conf.getFloat(
YarnConfiguration.QUOTA_MULTIPLICATOR_THRESHOLD_GPU,
YarnConfiguration.DEFAULT_QUOTA_MULTIPLICATOR_THRESHOLD_GPU));
this.incrementFactors.put(PriceMultiplicator.MultiplicatorType.GENERAL, this.conf.getFloat(
YarnConfiguration.QUOTA_INCREMENT_FACTOR_GENERAL,
YarnConfiguration.DEFAULT_QUOTA_INCREMENT_FACTOR_GENERAL));
this.incrementFactors.put(PriceMultiplicator.MultiplicatorType.GPU, this.conf.getFloat(
YarnConfiguration.QUOTA_INCREMENT_FACTOR_GPU,
YarnConfiguration.DEFAULT_QUOTA_INCREMENT_FACTOR_GPU));
this.priceMultiplicationFactorCalculationInterval = this.conf.getLong(
YarnConfiguration.QUOTA_PRICE_MULTIPLICATOR_INTERVAL,
YarnConfiguration.DEFAULT_QUOTA_PRICE_MULTIPLICATOR_INTERVAL);
// Initialize DataAccesses
this.priceMultiplicatorDA = (PriceMultiplicatorDataAccess) RMStorageFactory.
getDataAccess(PriceMultiplicatorDataAccess.class);
for(PriceMultiplicator.MultiplicatorType type: PriceMultiplicator.MultiplicatorType.values()){
currentMultiplicators.put(type, new Float(1));
}
recover();
}
示例9: recover
import io.hops.metadata.yarn.entity.quota.PriceMultiplicator; //导入依赖的package包/类
private void recover() throws IOException {
Map<PriceMultiplicator.MultiplicatorType, PriceMultiplicator> currentMultiplicators = getCurrentMultiplicator();
for (PriceMultiplicator.MultiplicatorType type : PriceMultiplicator.MultiplicatorType.values()) {
if (currentMultiplicators.get(type) != null) {
this.currentMultiplicators.put(type, currentMultiplicators.get(type).getValue());
}
}
}
示例10: computeNewGpuPrice
import io.hops.metadata.yarn.entity.quota.PriceMultiplicator; //导入依赖的package包/类
protected void computeNewGpuPrice() {
QueueMetrics metrics = rmcontext.getScheduler().getRootQueueMetrics();
float incrementBase = getPercenUsedGpus(metrics) - tippingPoints.get(PriceMultiplicator.MultiplicatorType.GPU);
incrementBase = Math.max(incrementBase, 0);
float multiplicator = 1 + incrementBase * incrementFactors.get(PriceMultiplicator.MultiplicatorType.GPU);
multiplicator = Math.max(multiplicator, currentMultiplicators.get(PriceMultiplicator.MultiplicatorType.GENERAL));
currentMultiplicators.put(PriceMultiplicator.MultiplicatorType.GPU, multiplicator);
LOG.debug("New multiplicator: " + currentMultiplicators + " (mem: "
+ getPercenUsedMB(metrics) + ", vcores: " + getPercenUsedCores(metrics) + ", gpus: "
+ getPercenUsedGpus(metrics) + ")");
}
示例11: computeNewGeneralPrice
import io.hops.metadata.yarn.entity.quota.PriceMultiplicator; //导入依赖的package包/类
protected void computeNewGeneralPrice() throws IOException {
QueueMetrics metrics = rmcontext.getScheduler().
getRootQueueMetrics();
float incrementBase = Math.max(getPercenUsedCores(metrics), getPercenUsedMB(metrics))
- tippingPoints.get(PriceMultiplicator.MultiplicatorType.GENERAL);
incrementBase = Math.max(incrementBase, 0);
currentMultiplicators.put(PriceMultiplicator.MultiplicatorType.GENERAL, 1 + incrementBase * incrementFactors.get(
PriceMultiplicator.MultiplicatorType.GENERAL));
LOG.debug("New multiplicator: " + currentMultiplicators + " (mem: "
+ getPercenUsedMB(metrics) + ", vcores: " + getPercenUsedCores(metrics) + ")");
}
示例12: CheckCurrentMultiplicator
import io.hops.metadata.yarn.entity.quota.PriceMultiplicator; //导入依赖的package包/类
private void CheckCurrentMultiplicator(final float generalMultiplicator, final float gpuMultiplicator) throws
Exception {
LightWeightRequestHandler currentMultiplicatorHandler
= new LightWeightRequestHandler(
YARNOperationType.TEST) {
@Override
public Object performTask() throws IOException {
connector.beginTransaction();
connector.writeLock();
PriceMultiplicatorDataAccess pmDA
= (PriceMultiplicatorDataAccess) RMStorageFactory.getDataAccess(
PriceMultiplicatorDataAccess.class);
Map<PriceMultiplicator.MultiplicatorType, PriceMultiplicator> priceList = pmDA.getAll();
connector.commit();
return priceList;
}
};
int nbTry=0;
Map<PriceMultiplicator.MultiplicatorType, PriceMultiplicator> currentMultiplicators = new HashMap<>();
while (nbTry < 10) {
currentMultiplicators
= (Map<PriceMultiplicator.MultiplicatorType, PriceMultiplicator>) currentMultiplicatorHandler.handle();
if (currentMultiplicators.get(PriceMultiplicator.MultiplicatorType.GENERAL).getValue() == generalMultiplicator
&& currentMultiplicators.get(PriceMultiplicator.MultiplicatorType.GPU).getValue() == gpuMultiplicator) {
break;
}
Thread.sleep(500);
nbTry++;
}
Assert.assertEquals(generalMultiplicator, currentMultiplicators.get(PriceMultiplicator.MultiplicatorType.GENERAL).
getValue(), 0);
Assert.
assertEquals(gpuMultiplicator, currentMultiplicators.get(PriceMultiplicator.MultiplicatorType.GPU).getValue(), 0);
}
示例13: getAll
import io.hops.metadata.yarn.entity.quota.PriceMultiplicator; //导入依赖的package包/类
Map<PriceMultiplicator.MultiplicatorType, T> getAll() throws
StorageException;
示例14: serviceInit
import io.hops.metadata.yarn.entity.quota.PriceMultiplicator; //导入依赖的package包/类
@Override
public void serviceInit(Configuration conf) throws Exception {
LOG.info("Initializing containers logs service");
this.conf = conf;
// Initialize config parameters
this.monitorInterval = this.conf.getLong(
YarnConfiguration.QUOTA_CONTAINERS_LOGS_MONITOR_INTERVAL,
YarnConfiguration.DEFAULT_QUOTA_CONTAINERS_LOGS_MONITOR_INTERVAL);
this.checkpointEnabled = this.conf.getBoolean(
YarnConfiguration.QUOTA_CONTAINERS_LOGS_CHECKPOINTS_ENABLED,
YarnConfiguration.DEFAULT_QUOTA_CONTAINERS_LOGS_CHECKPOINTS_ENABLED);
this.checkpointInterval = this.conf.getInt(
YarnConfiguration.QUOTA_CONTAINERS_LOGS_CHECKPOINTS_MINTICKS,
YarnConfiguration.DEFAULT_QUOTA_CONTAINERS_LOGS_CHECKPOINTS_MINTICKS)
* this.conf.getInt(YarnConfiguration.QUOTA_MIN_TICKS_CHARGE,
YarnConfiguration.DEFAULT_QUOTA_MIN_TICKS_CHARGE);
this.multiplicatorPeirod = this.conf.getLong(
YarnConfiguration.QUOTA_FIXED_MULTIPLICATOR_PERIOD,
YarnConfiguration.DEFAULT_QUOTA_FIXED_MULTIPLICATOR_PERIOD)
* checkpointInterval;
for(PriceMultiplicator.MultiplicatorType type: PriceMultiplicator.MultiplicatorType.values()){
currentMultiplicators.put(type, new Float(1));
}
// Initialize DataAccesses
containersLogsDA = (ContainersLogsDataAccess) RMStorageFactory.
getDataAccess(ContainersLogsDataAccess.class);
variableDA = (VariableDataAccess) RMStorageFactory.getDataAccess(
VariableDataAccess.class);
// Creates separate thread for retrieving container statuses
tickThread = new Thread(new TickThread());
tickThread.setName("ContainersLogs Tick Thread");
tickThread.setDaemon(true);
super.serviceInit(conf);
}
示例15: setCurrentPrices
import io.hops.metadata.yarn.entity.quota.PriceMultiplicator; //导入依赖的package包/类
public synchronized void setCurrentPrices(Map<PriceMultiplicator.MultiplicatorType,Float> currentPrices) {
this.currentMultiplicators = currentPrices;
}