|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.webSvr.ads.AdUtils
public final class AdUtils
Advertising-related utility functions. One advantage of having code here rather than in-line in a JSP is that it is pre-compiled off-line for speed and robustness; code here is also potentially easier to test.
| Nested Class Summary | |
|---|---|
static class |
AdUtils.AdSlotMonitor
Unique thread-safe marker tag and stats object for a particular ad slot. |
private static class |
AdUtils.ClickThruHandler
Handler for ad click-throughs; designed not to retain important strong refs. |
| Field Summary | |
|---|---|
private static DataSourceBean.UnlinkedKey |
_cache_sAMPIL_key
Key for thread-safe cache from Web site (DataSourceBean) to computed results for selectAdMidPageInternalLayout(); never null. |
private static DataSourceBean.UnlinkedKey |
_cache_sATIL_key
Key for thread-safe cache from Web site (DataSourceBean) to computed results for selectAdTowerInternalLayout(); never null. |
private static DataSourceBean.UnlinkedKey |
_cache_sPAL_key
Key for thread-safe cache from Web site (DataSourceBean) to computed results for selectPageAdLayout(); never null. |
private static int |
ADSLOTMONIOR_TIME_CONST
Time constant to use for ageing any memory of ad slot run times; strictly positive. |
private static int |
AMPI_NFORMATS
Number of distinct mid-page ad formats; strictly positive. |
private static long |
BEST_AD_LAYOUT_SAMPLE_PERIOD_MIN_MS
Minimum sample period to decide which is best-performing layout, ms; strictly positive. |
private static int |
BEST_AD_LAYOUT_SAMPLE_PERIOD_MIN_VLONG_UNITS
Ad-layout selection period expressed in VLONG units; strictly positive. |
private static int |
CLICKTHRU_MIN_WAIT_TIME_MS
Time we wait for a user to click through on ads (of the order of minutes), in ms. |
private static int |
DA_MAX_EXHIBITS_TO_SHOW
Maximum exhibits to show in drop-in ad-tower replacement text; strictly positive. |
private static int |
KHIT_THRESHOLD
Threshold (in thousands) when we switch from logging individual hits/clicks to thousands; strictly positive. |
private static int |
LITE_AD_SHOW_FRACTION
What fraction of ad slots are shown in "lite" mode; strictly positive. |
static int |
LOCAL_AD_STATS_WEIGHTING
Extra weighting in ad layout/format decisions given to local hits/stats; non-negative. |
private static int |
MAX_SIGNIFICANT_URI_PREFIX
Maximum leading portion of request URI that we will consider significant. |
private static int |
MIN_LOCAL_STATS_PAGEVIEWS
Minimum number of pageviews to accept one of the local stats values; strictly positive. |
static AdMidPageInternalLayout |
PREF_MP_FORMAT
Preferred mid-page ad format. |
private static java.util.EnumMap<AdTowerPos,java.util.concurrent.atomic.AtomicInteger> |
pvLayoutHits
Counters of page/ad basic layout-style used, indexed by AdTowerPos; never null. |
private static java.util.EnumMap<AdMidPageInternalLayout,java.util.concurrent.atomic.AtomicInteger> |
pvMPInternalFormatHits
Counters of page/ad basic tower format used, indexed by AdMInternalLayout; never null. |
private static java.util.EnumMap<AdTowerInternalLayout,java.util.concurrent.atomic.AtomicInteger> |
pvTowerInternalFormatHits
Counters of page/ad basic tower format used, indexed by AdTowerInternalLayout; never null. |
private static int |
TOP_N_RANK_AD_LIMIT
Ranking threshold assumed to indicate "well" ranked amongst many peers; strictly positive. |
private static int |
WT__VLONG_UNITS
Recent-stats weighting period (1 week) expressed in VLONG units; strictly positive. |
private static int |
WT_LAST_WEEK
Extra weighting given to "within last week" clickthrough stats (normal==1); strictly positive. |
private static int |
WT_THIS_DAY_LAST_WEEK
Extra weighting given to "this day last week" clickthrough stats (normal==1); strictly positive. |
| Constructor Summary | |
|---|---|
private |
AdUtils()
Prevent construction of an instance. |
| Method Summary | ||
|---|---|---|
private static
|
_computeOptimalLayout(java.lang.String callerName,
DataSourceBean dsb,
java.lang.String layoutKHitsEventPrefix,
java.lang.String ctEventPrefix,
DataSourceBean.UnlinkedKey cacheKey,
E defaultValue)
Return optimal value(s) best-first of parameter based on past data, recomputing/cacheing as needed; never null. |
|
static java.lang.String |
canonicaliseURI(java.lang.String uri)
Canonicalise URI (lower-case and truncate if need be; null is returned as null. |
|
static java.lang.String |
computeCTEventName(AdTowerPos towerPos)
Compute the full event name for recording a clickthrough with a particular layout style. |
|
static int |
computeECPC(GenProps gp,
java.lang.String statName)
Compute value (in arbitrary units) of named click-though; non-negative. |
|
static int |
computeECPM(GenProps gp,
java.lang.String statName)
Compute value (in arbitrary units) of named thousand CPM-ad-display impressions; non-negative. |
|
private static void |
countPageImpressions(java.util.concurrent.atomic.AtomicInteger count,
DataSourceBean dsb,
java.lang.String kHitName)
Count page impressions in this layout/ad-style. |
|
static java.lang.String |
createAndFileClickThruListener(javax.servlet.http.HttpServletRequest request,
SimpleVariablePipelineIF vars,
java.lang.String... otherTags)
Create and post the handler for a click-through if possible and returns the unique listenerID. |
|
static java.lang.String |
generateAdTowerFallbackHTML(javax.servlet.ServletContext application,
LocaleBean localeBean,
int pxWidth,
int pxHeight)
Get the HTML content for a fall-back/fill-in ad-tower filler; never null but may be "". |
|
private static java.lang.String |
make1HitName(java.lang.String kHitName)
Make single-hit event name from k-hit name, or return null if not possible. |
|
static AdMidPageInternalLayout |
selectAdMidPageInternalLayout(DataSourceBean dsb,
javax.servlet.http.HttpServletRequest request)
Chose internal layout of ad mid-age slot to be shown on page; never null. |
|
static AdTowerInternalLayout |
selectAdTowerInternalLayout(DataSourceBean dsb,
javax.servlet.http.HttpServletRequest request)
Chose internal layout of ad tower(s) to be shown on page; never null. |
|
static AdTowerPos |
selectPageAdLayout(DataSourceBean dsb,
javax.servlet.http.HttpServletRequest request,
boolean siteIsBusy,
boolean probeOnly)
Choose general ad/page layout; never null. |
|
static boolean |
showAds(DataSourceBean dsb,
javax.servlet.http.HttpServletRequest request)
Show ads or not on the current page and/or in the current slot? Returns false if ads are generally disabled, etc, though even in the case that the user session has been set to "lite" mode, will return true a small fraction of the time so as to show occasional ads. |
|
static boolean |
showAds(DataSourceBean dsb,
javax.servlet.http.HttpServletRequest request,
AdUtils.AdSlotMonitor monitor)
Show ads or not on the current page and/or in the current slot? Returns false if ads are generally disabled, etc, though even in the case that the user session has been set to "lite" mode, will return true a small fraction of the time so as to show occasional ads. |
|
static boolean |
skipUnderperformingAdSlot(SimpleVariablePipelineIF vars,
SimpleVariableDefinition history,
EventPeriod eventPeriod,
java.lang.Object slotIdentifier)
Decides if an underperforming ad slot should be skipped (ie not filled). |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final int KHIT_THRESHOLD
Ideally this should be large enough that loss of a nearly full "k-click" should not be hugely significant, which implies a value of maybe 10 or more.
We should set this as low as we can bear in terms of potential statistical inaccuracy to keep log traffic reasonable.
public static final int LOCAL_AD_STATS_WEIGHTING
A weighting of zero means to not treat local stats specially, and just use the global stats (which includes the local stats).
A weighting of 1 gives local stats equal weight to global stats, though clicks (etc) are recorded once in the global stats already, so that means that local stats are effectively given somewhat higher weight.
Note that the weighting is usually in terms of the entire eCPM/eCTR/etc (providing that there are enough local pageviews to keep noise acceptable, else the local stats may be ignored or used in a more-noise-tolerant way), and thus even low-traffic mirrors can show significant favour to local mores.
private static final int MIN_LOCAL_STATS_PAGEVIEWS
NB: Google AdWords seems to regard 1000 as a minimum sensible sample size.
A value of 1000 up to some fraction of our KHIT_THRESHOLD may be good.
private static final int TOP_N_RANK_AD_LIMIT
private static final int LITE_AD_SHOW_FRACTION
private static final int ADSLOTMONIOR_TIME_CONST
private static final int MAX_SIGNIFICANT_URI_PREFIX
private static final int CLICKTHRU_MIN_WAIT_TIME_MS
private static final long BEST_AD_LAYOUT_SAMPLE_PERIOD_MIN_MS
(It may be wise to factor in a small component of the all-time numbers.)
A length of just over a week-multiple (to give some extra emphasis to patterns pertient to the day just coming up) may be good.
private static final int BEST_AD_LAYOUT_SAMPLE_PERIOD_MIN_VLONG_UNITS
private static final int WT_LAST_WEEK
private static final int WT_THIS_DAY_LAST_WEEK
private static final int WT__VLONG_UNITS
private static final java.util.EnumMap<AdTowerInternalLayout,java.util.concurrent.atomic.AtomicInteger> pvTowerInternalFormatHits
All values will be non-negative, and usually less than 1000.
FIXME: should be keyed from DataSourceBean to allow for multiple sites in one VM.
private static final DataSourceBean.UnlinkedKey _cache_sAMPIL_key
public static final AdMidPageInternalLayout PREF_MP_FORMAT
private static final int AMPI_NFORMATS
private static final java.util.EnumMap<AdMidPageInternalLayout,java.util.concurrent.atomic.AtomicInteger> pvMPInternalFormatHits
All values will be non-negative, and usually less than 1000.
FIXME: should be keyed from DataSourceBean to allow for multiple sites in one VM.
private static final DataSourceBean.UnlinkedKey _cache_sATIL_key
private static final DataSourceBean.UnlinkedKey _cache_sPAL_key
private static final java.util.EnumMap<AdTowerPos,java.util.concurrent.atomic.AtomicInteger> pvLayoutHits
All values will be non-negative, and usually less than 1000.
FIXME: should be keyed from DataSourceBean to allow for multiple sites in one VM.
private static final int DA_MAX_EXHIBITS_TO_SHOW
| Constructor Detail |
|---|
private AdUtils()
| Method Detail |
|---|
public static final boolean showAds(DataSourceBean dsb,
javax.servlet.http.HttpServletRequest request)
We don't show ads if they've been explicitly disabled system-wide, or if the URI seems to indicate possibly-sensitive content...
Doesn't monitor a particular ad slot, ie is yes/no for the whole page, and thus nominally the result is the same whenever and however often called on a page, though we might start saying no if it has been a long time since this page's generation started.
public static final boolean showAds(DataSourceBean dsb,
javax.servlet.http.HttpServletRequest request,
AdUtils.AdSlotMonitor monitor)
We don't show ads if they've been explicitly disabled system-wide, or if the URI seems to indicate possibly-sensitive content...
monitor - if non-null should be a unique monitor token
associated with one ad slot (or group of slots)
to time how long it takes to generate content for that slot
and decide whether to avoid showing the ad at all;
only appropriate for server-side inserted ads
public static boolean skipUnderperformingAdSlot(SimpleVariablePipelineIF vars,
SimpleVariableDefinition history,
EventPeriod eventPeriod,
java.lang.Object slotIdentifier)
Reducing the number of (non-performing) ads shown to users probably improves the user experience in various ways and probably also increases the effective revenue from other slots.
The system variable may represent something such as page views or CTR.
This must not throw any exceptions so as to avoid killing any JSP that it happens to be called from.
TODO: May want to factor in local stats specially at some point.
vars - handle on the system variables; never nullhistory - event history (definition) to be examined; never nulleventPeriod - period we are interested in from event history;
must be valid for the given event and non-nullslotIdentifier - the unique ID for advertising "events" for this slot;
must be valid value and type for specified history and non-null
public static java.lang.String createAndFileClickThruListener(javax.servlet.http.HttpServletRequest request,
SimpleVariablePipelineIF vars,
java.lang.String... otherTags)
This returns null if we could not create a listener.
request - client's HTTP request; never nullvars - where stats updates are posted; never nullotherTags - any non-null (and non-empty) values
(which should be distinctive but short)
are recorded to GENSTATS_STRING_GLOBAL_EVENT upon a click-through
public static java.lang.String canonicaliseURI(java.lang.String uri)
public static int computeECPM(GenProps gp,
java.lang.String statName)
public static int computeECPC(GenProps gp,
java.lang.String statName)
private static <E extends java.lang.Enum<E>> java.util.List<E> _computeOptimalLayout(java.lang.String callerName,
DataSourceBean dsb,
java.lang.String layoutKHitsEventPrefix,
java.lang.String ctEventPrefix,
DataSourceBean.UnlinkedKey cacheKey,
E defaultValue)
throws java.lang.InterruptedException
defaultValue - the default value to use
when we cannot (immediately) compute the optimum; never null
java.lang.InterruptedException
public static final AdMidPageInternalLayout selectAdMidPageInternalLayout(DataSourceBean dsb,
javax.servlet.http.HttpServletRequest request)
throws java.lang.InterruptedException
May collect stats on layout to help monitor/select the most effective.
request - the RQPNAME_MIDPAGEINTLAYOUT attribute is set
to indicate which format has been selected
java.lang.InterruptedException
private static void countPageImpressions(java.util.concurrent.atomic.AtomicInteger count,
DataSourceBean dsb,
java.lang.String kHitName)
private static java.lang.String make1HitName(java.lang.String kHitName)
public static final AdTowerInternalLayout selectAdTowerInternalLayout(DataSourceBean dsb,
javax.servlet.http.HttpServletRequest request)
throws java.lang.InterruptedException
May collect stats on layout to help monitor/select the most effective.
request - the RQPNAME_TOWERINTLAYOUT attribute is set
to indicate which format has been selected
java.lang.InterruptedException
public static final AdTowerPos selectPageAdLayout(DataSourceBean dsb,
javax.servlet.http.HttpServletRequest request,
boolean siteIsBusy,
boolean probeOnly)
throws java.lang.InterruptedException
May collect stats on layout to help monitor/select the most effective.
Note that most effective combo seems to be:
Computed values may be cached wrt the DataSourceBean variable, so should consistently be called with the same instance for one site.
probeOnly - this call is to find out what
the layout should be,
and should not count as a page view
java.lang.InterruptedExceptionpublic static java.lang.String computeCTEventName(AdTowerPos towerPos)
public static java.lang.String generateAdTowerFallbackHTML(javax.servlet.ServletContext application,
LocaleBean localeBean,
int pxWidth,
int pxHeight)
|
DHD Multimedia Gallery V1.53.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||