mitreid-connect
公開メンバ関数 | 限定公開メンバ関数 | 非公開メンバ関数 | 全メンバ一覧
org.mitre.data.AbstractPageOperationTemplateTest.NullPageCountingPageOperation クラス
org.mitre.data.AbstractPageOperationTemplateTest.NullPageCountingPageOperation の継承関係図
Inheritance graph
org.mitre.data.AbstractPageOperationTemplateTest.NullPageCountingPageOperation 連携図
Collaboration graph

公開メンバ関数

Collection< String > fetchPage ()
 
long getCounter ()
 
long getTimeToLastFetch ()
 
long getTimeToPreviousFetch ()
 
void execute ()
 
int getMaxPages ()
 
void setMaxPages (int maxPages)
 
long getMaxTime ()
 
void setMaxTime (long maxTime)
 
boolean isSwallowExceptions ()
 
void setSwallowExceptions (boolean swallowExceptions)
 
String getOperationName ()
 
void setOperationName (String operationName)
 

限定公開メンバ関数

void doOperation (String item)
 
abstract void doOperation (T item)
 
void finalReport (int operationsCompleted, int exceptionsSwallowedCount, Set< String > exceptionsSwallowedClasses)
 

非公開メンバ関数

 NullPageCountingPageOperation (int maxPages, long maxTime)
 

詳解

構築子と解体子

◆ NullPageCountingPageOperation()

org.mitre.data.AbstractPageOperationTemplateTest.NullPageCountingPageOperation.NullPageCountingPageOperation ( int  maxPages,
long  maxTime 
)
inlineprivate
192  {
193  super(maxPages, maxTime);
194  }
long maxTime
Definition: AbstractPageOperationTemplate.java:50
int maxPages
Definition: AbstractPageOperationTemplate.java:44

関数詳解

◆ doOperation() [1/2]

abstract void org.mitre.data.AbstractPageOperationTemplate< T >.doOperation ( item)
abstractprotectedinherited

method responsible for performing desired operation on a fetched page item.

引数
itemthe item

◆ doOperation() [2/2]

void org.mitre.data.AbstractPageOperationTemplateTest.CountingPageOperation.doOperation ( String  item)
inlineprotectedinherited
174  {
175  counter++;
176  }
long counter
Definition: AbstractPageOperationTemplateTest.java:150

◆ execute()

void org.mitre.data.AbstractPageOperationTemplate< T >.execute ( )
inlineinherited

Execute the operation on each member of a page of results retrieved through the fetch method. the method will execute until either the maxPages or maxTime limit is reached or until the fetch method returns no more results. Exceptions thrown performing the operation on the item will be swallowed if the swallowException (default true) field is set true.

95  {
96  logger.debug("[" + getOperationName() + "] Starting execution of paged operation. maximum time: " + maxTime + ", maximum pages: " + maxPages);
97 
98  long startTime = System.currentTimeMillis();
99  long executionTime = 0;
100  int i = 0;
101 
102  int exceptionsSwallowedCount = 0;
103  int operationsCompleted = 0;
104  Set<String> exceptionsSwallowedClasses = new HashSet<String>();
105 
106 
107  while (i< maxPages && executionTime < maxTime){
108  Collection<T> page = fetchPage();
109  if(page == null || page.size() == 0){
110  break;
111  }
112 
113  for (T item : page) {
114  try {
115  doOperation(item);
116  operationsCompleted++;
117  } catch (Exception e){
118  if(swallowExceptions){
119  exceptionsSwallowedCount++;
120  exceptionsSwallowedClasses.add(e.getClass().getName());
121  logger.debug("Swallowing exception " + e.getMessage(), e);
122  } else {
123  logger.debug("Rethrowing exception " + e.getMessage());
124  throw e;
125  }
126  }
127  }
128 
129  i++;
130  executionTime = System.currentTimeMillis() - startTime;
131  }
132 
133  finalReport(operationsCompleted, exceptionsSwallowedCount, exceptionsSwallowedClasses);
134  }
long maxTime
Definition: AbstractPageOperationTemplate.java:50
boolean swallowExceptions
Definition: AbstractPageOperationTemplate.java:57
int maxPages
Definition: AbstractPageOperationTemplate.java:44
String getOperationName()
Definition: AbstractPageOperationTemplate.java:195
void finalReport(int operationsCompleted, int exceptionsSwallowedCount, Set< String > exceptionsSwallowedClasses)
Definition: AbstractPageOperationTemplate.java:158
static final Logger logger
Definition: AbstractPageOperationTemplate.java:34

◆ fetchPage()

Collection<String> org.mitre.data.AbstractPageOperationTemplateTest.NullPageCountingPageOperation.fetchPage ( )
inline
197  {
198  return null;
199  }

◆ finalReport()

void org.mitre.data.AbstractPageOperationTemplate< T >.finalReport ( int  operationsCompleted,
int  exceptionsSwallowedCount,
Set< String >  exceptionsSwallowedClasses 
)
inlineprotectedinherited

Method responsible for final report of progress.

戻り値
158  {
159  if (operationsCompleted > 0 || exceptionsSwallowedCount > 0) {
160  logger.info("[" + getOperationName() + "] Paged operation run: completed " + operationsCompleted + "; swallowed " + exceptionsSwallowedCount + " exceptions");
161  }
162  for(String className: exceptionsSwallowedClasses) {
163  logger.warn("[" + getOperationName() + "] Paged operation swallowed at least one exception of type " + className);
164  }
165  }
String getOperationName()
Definition: AbstractPageOperationTemplate.java:195
static final Logger logger
Definition: AbstractPageOperationTemplate.java:34

◆ getCounter()

long org.mitre.data.AbstractPageOperationTemplateTest.CountingPageOperation.getCounter ( )
inlineinherited
178  {
179  return counter;
180  }
long counter
Definition: AbstractPageOperationTemplateTest.java:150

◆ getMaxPages()

int org.mitre.data.AbstractPageOperationTemplate< T >.getMaxPages ( )
inlineinherited
167  {
168  return maxPages;
169  }
int maxPages
Definition: AbstractPageOperationTemplate.java:44

◆ getMaxTime()

long org.mitre.data.AbstractPageOperationTemplate< T >.getMaxTime ( )
inlineinherited
175  {
176  return maxTime;
177  }
long maxTime
Definition: AbstractPageOperationTemplate.java:50

◆ getOperationName()

String org.mitre.data.AbstractPageOperationTemplate< T >.getOperationName ( )
inlineinherited
戻り値
the operationName
195  {
196  return operationName;
197  }
String operationName
Definition: AbstractPageOperationTemplate.java:62

◆ getTimeToLastFetch()

long org.mitre.data.AbstractPageOperationTemplateTest.CountingPageOperation.getTimeToLastFetch ( )
inlineinherited
182  {
183  return timeToLastFetch;
184  }
long timeToLastFetch
Definition: AbstractPageOperationTemplateTest.java:152

◆ getTimeToPreviousFetch()

long org.mitre.data.AbstractPageOperationTemplateTest.CountingPageOperation.getTimeToPreviousFetch ( )
inlineinherited
186  {
187  return timeToPreviousFetch;
188  }
long timeToPreviousFetch
Definition: AbstractPageOperationTemplateTest.java:153

◆ isSwallowExceptions()

boolean org.mitre.data.AbstractPageOperationTemplate< T >.isSwallowExceptions ( )
inlineinherited
183  {
184  return swallowExceptions;
185  }
boolean swallowExceptions
Definition: AbstractPageOperationTemplate.java:57

◆ setMaxPages()

void org.mitre.data.AbstractPageOperationTemplate< T >.setMaxPages ( int  maxPages)
inlineinherited
171  {
172  this.maxPages = maxPages;
173  }
int maxPages
Definition: AbstractPageOperationTemplate.java:44

◆ setMaxTime()

void org.mitre.data.AbstractPageOperationTemplate< T >.setMaxTime ( long  maxTime)
inlineinherited
179  {
180  this.maxTime = maxTime;
181  }
long maxTime
Definition: AbstractPageOperationTemplate.java:50

◆ setOperationName()

void org.mitre.data.AbstractPageOperationTemplate< T >.setOperationName ( String  operationName)
inlineinherited
引数
operationNamethe operationName to set
203  {
205  }
String operationName
Definition: AbstractPageOperationTemplate.java:62

◆ setSwallowExceptions()

void org.mitre.data.AbstractPageOperationTemplate< T >.setSwallowExceptions ( boolean  swallowExceptions)
inlineinherited
187  {
189  }
boolean swallowExceptions
Definition: AbstractPageOperationTemplate.java:57

このクラス詳解は次のファイルから抽出されました: