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
;
5 import static com
.google
.appengine
.tools
.appstats
.StatsProtos
.BilledOpProto
.BilledOp
.CHANNEL_PRESENCE
;
6 import static com
.google
.appengine
.tools
.appstats
.StatsProtos
.BilledOpProto
.BilledOp
.DATASTORE_READ
;
7 import static com
.google
.appengine
.tools
.appstats
.StatsProtos
.BilledOpProto
.BilledOp
.DATASTORE_SMALL
;
8 import static com
.google
.appengine
.tools
.appstats
.StatsProtos
.BilledOpProto
.BilledOp
.DATASTORE_WRITE
;
9 import static com
.google
.appengine
.tools
.appstats
.StatsProtos
.BilledOpProto
.BilledOp
.MAIL_RECIPIENT
;
10 import static com
.google
.appengine
.tools
.appstats
.StatsProtos
.BilledOpProto
.BilledOp
.XMPP_STANZA
;
12 import com
.google
.appengine
.tools
.appstats
.StatsProtos
.BilledOpProto
.BilledOp
;
13 import com
.google
.common
.collect
.Maps
;
18 * {@link RpcOperationCostManager} implementation with all the costs hard-coded.
21 class StaticRpcOperationCostManager
implements RpcOperationCostManager
{
23 private static final long MILLION
= 1000000;
24 private static final long PER_HUNDRED_THOUSAND
= MILLION
/ 100000;
25 private static final long PER_THOUSAND
= MILLION
/ 1000;
26 private static final long PER_HUNDRED
= MILLION
/ 100;
28 static final Map
<BilledOp
, Long
> COST_MAP
;
31 COST_MAP
= Maps
.newHashMap();
33 COST_MAP
.put(DATASTORE_READ
, perHundredThousand(7));
35 COST_MAP
.put(DATASTORE_WRITE
, perHundredThousand(10));
37 COST_MAP
.put(DATASTORE_SMALL
, perHundredThousand(1));
39 COST_MAP
.put(MAIL_RECIPIENT
, perThousand(1));
41 COST_MAP
.put(CHANNEL_OPEN
, perHundred(1));
43 COST_MAP
.put(XMPP_STANZA
, perHundredThousand(10));
45 COST_MAP
.put(CHANNEL_PRESENCE
, 0L);
48 private static long perHundredThousand(long centsPerHundredThousand
) {
49 return centsPerHundredThousand
* PER_HUNDRED_THOUSAND
;
53 private static long perThousand(long centsPerThousand
) {
54 return centsPerThousand
* PER_THOUSAND
;
58 private static long perHundred(long centsPerHundred
) {
59 return centsPerHundred
* PER_HUNDRED
;
64 public long costOf(BilledOp op
) {
65 return COST_MAP
.get(op
);