1 // Copyright 2012 Google Inc. All Rights Reserved.
2 package com
.google
.appengine
.tools
.appstats
;
4 import static com
.google
.appengine
.tools
.appstats
.StatsProtos
.BilledOpProto
.BilledOp
.CHANNEL_OPEN
;
6 import java
.util
.Arrays
;
10 * {@link RpcCostCalculator} implementation for the Channel API.
13 class ChannelRpcCostCalculator
implements RpcCostCalculator
{
15 private static final String PKG
= "channel";
17 private final StatsProtos
.BilledOpProto billedOpProto
=
18 StatsProtos
.BilledOpProto
.newBuilder().setNumOps(1).setOp(CHANNEL_OPEN
).build();
20 private final RpcCost channelOpenCostMicropennies
;
22 ChannelRpcCostCalculator(long channelOpenCostMicropennies
) {
23 this.channelOpenCostMicropennies
=
24 new RpcCost(channelOpenCostMicropennies
, Arrays
.asList(billedOpProto
));
28 public RpcCost
determineCost(String methodName
, byte[] request
, byte[] response
) {
29 if (methodName
.equals("CreateChannel")) {
30 return channelOpenCostMicropennies
;
36 Map
<String
, RpcCostCalculator
> costCalculatorMap
, RpcOperationCostManager opCostMgr
) {
37 costCalculatorMap
.put(PKG
, new ChannelRpcCostCalculator(opCostMgr
.costOf(CHANNEL_OPEN
)));