Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
adapt
ace
Commits
2154c5b8
Commit
2154c5b8
authored
Apr 06, 2017
by
Michael Ritter
Browse files
Only update a group summary if the collection has changed
parent
c750a2d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
ace-am/src/main/java/edu/umiacs/ace/monitor/access/CollectionCountContext.java
View file @
2154c5b8
...
@@ -46,6 +46,7 @@ import java.sql.PreparedStatement;
...
@@ -46,6 +46,7 @@ import java.sql.PreparedStatement;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.locks.Lock
;
import
java.util.concurrent.locks.Lock
;
import
java.util.concurrent.locks.ReentrantLock
;
import
java.util.concurrent.locks.ReentrantLock
;
...
@@ -62,16 +63,16 @@ public class CollectionCountContext implements ServletContextListener {
...
@@ -62,16 +63,16 @@ public class CollectionCountContext implements ServletContextListener {
public
static
final
String
CTX_STARTUP
=
"startup_complete"
;
public
static
final
String
CTX_STARTUP
=
"startup_complete"
;
private
static
final
Logger
LOG
=
Logger
.
getLogger
(
private
static
final
Logger
LOG
=
Logger
.
getLogger
(
CollectionCountContext
.
class
);
CollectionCountContext
.
class
);
private
static
Map
<
Collection
,
Long
>
fileCountMap
=
new
HashMap
<
Collection
,
Long
>();
private
static
Map
<
Collection
,
Long
>
fileCountMap
=
new
HashMap
<>();
private
static
Map
<
Collection
,
Long
>
fileActiveMap
=
new
HashMap
<
Collection
,
Long
>();
private
static
Map
<
Collection
,
Long
>
fileActiveMap
=
new
HashMap
<>();
private
static
Map
<
Collection
,
Long
>
fileCorruptMap
=
new
HashMap
<
Collection
,
Long
>();
private
static
Map
<
Collection
,
Long
>
fileCorruptMap
=
new
HashMap
<>();
private
static
Map
<
Collection
,
Long
>
fileMissingMap
=
new
HashMap
<
Collection
,
Long
>();
private
static
Map
<
Collection
,
Long
>
fileMissingMap
=
new
HashMap
<>();
private
static
Map
<
Collection
,
Long
>
fileMissingTokenMap
=
new
HashMap
<
Collection
,
Long
>();
private
static
Map
<
Collection
,
Long
>
fileMissingTokenMap
=
new
HashMap
<>();
private
static
Map
<
Collection
,
Long
>
fileTokenMismatchMap
=
new
HashMap
<
Collection
,
Long
>();
private
static
Map
<
Collection
,
Long
>
fileTokenMismatchMap
=
new
HashMap
<>();
private
static
Map
<
Collection
,
Long
>
totalErrorMap
=
new
HashMap
<
Collection
,
Long
>();
private
static
Map
<
Collection
,
Long
>
totalErrorMap
=
new
HashMap
<>();
private
static
Map
<
Collection
,
Long
>
totalSizeMap
=
new
HashMap
<
Collection
,
Long
>();
private
static
Map
<
Collection
,
Long
>
totalSizeMap
=
new
HashMap
<>();
private
static
Map
<
Collection
,
Long
>
fileRemoteMissing
=
new
HashMap
<
Collection
,
Long
>();
private
static
Map
<
Collection
,
Long
>
fileRemoteMissing
=
new
HashMap
<>();
private
static
Map
<
Collection
,
Long
>
fileRemoteCorrupt
=
new
HashMap
<
Collection
,
Long
>();
private
static
Map
<
Collection
,
Long
>
fileRemoteCorrupt
=
new
HashMap
<>();
private
static
AtomicInteger
totalCollections
=
new
AtomicInteger
(
0
);
private
static
AtomicInteger
totalCollections
=
new
AtomicInteger
(
0
);
private
static
Lock
lock
=
new
ReentrantLock
();
private
static
Lock
lock
=
new
ReentrantLock
();
private
static
boolean
abort
=
false
;
private
static
boolean
abort
=
false
;
...
@@ -226,10 +227,11 @@ public class CollectionCountContext implements ServletContextListener {
...
@@ -226,10 +227,11 @@ public class CollectionCountContext implements ServletContextListener {
/**
/**
* Update statistics for a collection.
* Update statistics for a collection.
*
*
* @param c
* @param c
*/
*/
private
static
void
queryCollection
(
Collection
c
)
{
private
static
boolean
queryCollection
(
Collection
c
)
{
boolean
update
=
false
;
Connection
connection
=
null
;
Connection
connection
=
null
;
PreparedStatement
ps
=
null
;
PreparedStatement
ps
=
null
;
ResultSet
rs
=
null
;
ResultSet
rs
=
null
;
...
@@ -249,14 +251,13 @@ public class CollectionCountContext implements ServletContextListener {
...
@@ -249,14 +251,13 @@ public class CollectionCountContext implements ServletContextListener {
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
if
(
abort
)
{
if
(
abort
)
{
return
;
return
update
;
}
}
char
state
=
rs
.
getString
(
1
).
charAt
(
0
);
char
state
=
rs
.
getString
(
1
).
charAt
(
0
);
long
count
=
rs
.
getLong
(
2
);
long
count
=
rs
.
getLong
(
2
);
total
+=
count
;
total
+=
count
;
switch
(
state
)
{
switch
(
state
)
{
case
'A'
:
case
'A'
:
fileActiveMap
.
put
(
c
,
count
);
fileActiveMap
.
put
(
c
,
count
);
...
@@ -288,7 +289,7 @@ public class CollectionCountContext implements ServletContextListener {
...
@@ -288,7 +289,7 @@ public class CollectionCountContext implements ServletContextListener {
}
}
}
}
fileCountMap
.
put
(
c
,
total
);
update
=
!
Objects
.
equals
(
fileCountMap
.
put
(
c
,
total
),
total
);
totalErrorMap
.
put
(
c
,
totalErrors
);
totalErrorMap
.
put
(
c
,
totalErrors
);
SQL
.
release
(
rs
);
SQL
.
release
(
rs
);
SQL
.
release
(
ps
);
SQL
.
release
(
ps
);
...
@@ -303,8 +304,7 @@ public class CollectionCountContext implements ServletContextListener {
...
@@ -303,8 +304,7 @@ public class CollectionCountContext implements ServletContextListener {
rs
=
ps
.
executeQuery
();
rs
=
ps
.
executeQuery
();
rs
.
next
();
rs
.
next
();
long
totalSize
=
rs
.
getLong
(
1
);
long
totalSize
=
rs
.
getLong
(
1
);
totalSizeMap
.
put
(
c
,
totalSize
);
update
=
update
|
!
Objects
.
equals
(
totalSizeMap
.
put
(
c
,
totalSize
),
totalSize
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Error starting up, collection count"
,
e
);
LOG
.
error
(
"Error starting up, collection count"
,
e
);
}
finally
{
}
finally
{
...
@@ -312,8 +312,9 @@ public class CollectionCountContext implements ServletContextListener {
...
@@ -312,8 +312,9 @@ public class CollectionCountContext implements ServletContextListener {
SQL
.
release
(
ps
);
SQL
.
release
(
ps
);
SQL
.
release
(
connection
);
SQL
.
release
(
connection
);
LOG
.
trace
(
"Finished count on "
+
c
.
getName
());
LOG
.
trace
(
"Finished count on "
+
c
.
getName
());
}
}
return
update
;
}
}
public
static
void
updateCollection
(
final
Collection
c
)
{
public
static
void
updateCollection
(
final
Collection
c
)
{
...
@@ -325,8 +326,10 @@ public class CollectionCountContext implements ServletContextListener {
...
@@ -325,8 +326,10 @@ public class CollectionCountContext implements ServletContextListener {
lock
.
lock
();
lock
.
lock
();
try
{
try
{
queryCollection
(
c
);
boolean
update
=
queryCollection
(
c
);
GroupSummaryContext
.
updateGroup
(
c
.
getGroup
());
if
(
update
)
{
GroupSummaryContext
.
updateGroup
(
c
.
getGroup
());
}
}
finally
{
}
finally
{
lock
.
unlock
();
lock
.
unlock
();
}
}
...
...
ace-am/src/main/java/edu/umiacs/ace/monitor/access/GroupSummaryContext.java
View file @
2154c5b8
...
@@ -57,6 +57,7 @@ public class GroupSummaryContext implements ServletContextListener {
...
@@ -57,6 +57,7 @@ public class GroupSummaryContext implements ServletContextListener {
*/
*/
public
static
void
updateGroup
(
String
group
)
{
public
static
void
updateGroup
(
String
group
)
{
if
(
group
!=
null
)
{
if
(
group
!=
null
)
{
log
.
debug
(
"Updating group summary for "
+
group
);
updateSummaries
(
updateSummaries
(
ImmutableList
.
of
(
SUMMARY_QUERY
,
SUMMARY_QUERY_PARAM
,
SUMMARY_QUERY_END
),
ImmutableList
.
of
(
SUMMARY_QUERY
,
SUMMARY_QUERY_PARAM
,
SUMMARY_QUERY_END
),
ImmutableList
.
of
(
group
));
ImmutableList
.
of
(
group
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment