Skip to content

Commit 480393f

Browse files
committed
init commit;
1 parent 7eeb046 commit 480393f

File tree

6 files changed

+131
-7
lines changed

6 files changed

+131
-7
lines changed

hollow-diff-ui/src/main/java/com/netflix/hollow/history/ui/HollowHistoryUI.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import java.util.HashMap;
4141
import java.util.Map;
4242
import java.util.TimeZone;
43+
import java.util.concurrent.ConcurrentHashMap;
4344
import javax.servlet.http.HttpServletRequest;
4445
import javax.servlet.http.HttpServletResponse;
4546

@@ -63,6 +64,15 @@ public class HollowHistoryUI extends HollowUIRouter implements HollowRecordDiffU
6364
private final TimeZone timeZone;
6465

6566
private String[] overviewDisplayHeaders;
67+
/** General purpose map to store header string and corresponding values used in HollowExplorer. It also stores headerDisplayString
68+
* for backwards compatibility.
69+
* use thread-safe map as value writer and renders may perform concurrent reads/writes.
70+
**/
71+
private final ConcurrentHashMap<String, String> commonHeadersDisplayMap = new ConcurrentHashMap<>();
72+
private final static String HEADER_DISPLAY_NAMESPACE = "headerDisplayNamespace";
73+
private final static String HEADER_DISPLAY_ENV="headerDisplayEnv";
74+
private final static String HEADER_DISPLAY_ENV_COLOR="headerDisplayEnvColor";
75+
private final static String HEADER_DISPLAY_PINNED_VERSION="headerDisplayPinnedVersion";
6676

6777
/**
6878
* HollowHistoryUI constructor that builds history for a consumer that transitions forwards i.e. in increasing
@@ -260,4 +270,37 @@ public HollowObjectViewProvider getViewProvider() {
260270
public TimeZone getTimeZone() {
261271
return timeZone;
262272
}
273+
274+
public String getHeaderDisplayNamespace() {
275+
return commonHeadersDisplayMap.get(HEADER_DISPLAY_NAMESPACE);
276+
}
277+
278+
public void setHeaderDisplayNamespace(String str) {
279+
this.commonHeadersDisplayMap.put(HEADER_DISPLAY_NAMESPACE, str);
280+
}
281+
282+
public String getHeaderDisplayEnv() {
283+
return commonHeadersDisplayMap.get(HEADER_DISPLAY_ENV);
284+
}
285+
286+
public void setHeaderDisplayEnv(String str) {
287+
this.commonHeadersDisplayMap.put(HEADER_DISPLAY_ENV, str);
288+
}
289+
290+
public String getHeaderDisplayEnvColor() {
291+
return this.commonHeadersDisplayMap.get(HEADER_DISPLAY_ENV_COLOR);
292+
}
293+
294+
public String setHeaderDisplayEnvColor(String str) {
295+
return this.commonHeadersDisplayMap.put(HEADER_DISPLAY_ENV_COLOR, str);
296+
}
297+
298+
public String getHeaderDisplayPinnedVersion() {
299+
return commonHeadersDisplayMap.get(HEADER_DISPLAY_PINNED_VERSION);
300+
}
301+
302+
public void setHeaderDisplayPinnedVersion(long version) {
303+
this.commonHeadersDisplayMap.put(HEADER_DISPLAY_PINNED_VERSION, Long.toString(version));
304+
}
305+
263306
}

hollow-diff-ui/src/main/java/com/netflix/hollow/history/ui/pages/HistoryPage.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,25 @@ public void render(HttpServletRequest req, HollowUISession session, Writer write
5757
throw e;
5858
}
5959

60+
String headerDisplayNamespace = ui.getHeaderDisplayNamespace();
61+
if (headerDisplayNamespace != null) {
62+
ctx.put("headerDisplayNamespace", headerDisplayNamespace);
63+
}
64+
65+
String headerDisplayEnv = ui.getHeaderDisplayEnv();
66+
if (headerDisplayEnv != null) {
67+
ctx.put("headerDisplayEnv", headerDisplayEnv);
68+
String headerDisplayEnvColor = ui.getHeaderDisplayEnvColor();
69+
if (headerDisplayEnvColor != null) {
70+
ctx.put("headerDisplayEnvColor", headerDisplayEnvColor);
71+
}
72+
}
73+
74+
String headerDisplayPinnedVersion = ui.getHeaderDisplayPinnedVersion();
75+
if (headerDisplayPinnedVersion != null) {
76+
ctx.put("headerDisplayPinnedVersion", headerDisplayPinnedVersion);
77+
}
78+
6079
if(includeHeaderAndFooter())
6180
headerTemplate.merge(ctx, writer);
6281
template.merge(ctx, writer);

hollow-diff-ui/src/main/resources/history-header.vm

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,28 @@
1818

1919
<head>
2020
<title>Hollow Data History</title>
21+
<style>
22+
.nav { text-align: left; padding-left: 5px; padding-right: 80px; border-left:1px solid #DCDCDC; }
23+
</style>
2124
</head>
2225

2326
<body>
24-
25-
#if($showHomeLink)
26-
<a href="$basePath/overview">Home</a>
27-
#end
27+
<table>
28+
<tr>
29+
#if($showHomeLink)
30+
<td class="nav"><a href="$basePath/overview">Home</a> </td>
31+
#end
32+
#if($headerDisplayEnv)
33+
<td class="nav">[ <span#if($headerDisplayEnvColor != "") style="color: $headerDisplayEnvColor;"#end>$headerDisplayEnv</span> ]</td>
34+
#end
35+
#if($headerDisplayNamespace)
36+
<td class="nav">[ $headerDisplayNamespace ]</td>
37+
#end
38+
#if($headerDisplayPinnedVersion)
39+
<td class="nav">[ Explorer is Pinned To: $headerDisplayPinnedVersion ]</td>
40+
#end
41+
</tr>
42+
</table>
2843

2944
<form action="$basePath/query">
3045
Lookup Key:

hollow-explorer-ui/src/main/java/com/netflix/hollow/explorer/ui/HollowExplorerUI.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import com.netflix.hollow.ui.HollowUIRouter;
2727
import com.netflix.hollow.ui.HollowUISession;
2828
import java.io.IOException;
29-
import java.util.HashMap;
29+
import java.util.concurrent.ConcurrentHashMap;
3030
import javax.servlet.http.HttpServletRequest;
3131
import javax.servlet.http.HttpServletResponse;
3232

@@ -38,9 +38,13 @@ public class HollowExplorerUI extends HollowUIRouter {
3838
private final HollowReadStateEngine stateEngine;
3939
/** General purpose map to store header string and corresponding values used in HollowExplorer. It also stores headerDisplayString
4040
* for backwards compatibility.
41+
* use thread-safe map as value writer and renders may perform concurrent reads/writes.
4142
**/
42-
private final HashMap<String, String> headerDisplayMap = new HashMap<>();
43+
private final ConcurrentHashMap<String, String> headerDisplayMap = new ConcurrentHashMap<>();
4344
private final static String HEADER_DISPLAY_STRING = "headerDisplayString";
45+
private final static String HEADER_DISPLAY_ENV="headerDisplayEnv";
46+
private final static String HEADER_DISPLAY_ENV_COLOR="headerDisplayEnvColor";
47+
private final static String HEADER_DISPLAY_PINNED_VERSION="headerDisplayPinnedVersion";
4448

4549
private final ShowAllTypesPage showAllTypesPage;
4650
private final BrowseSelectedTypePage browseTypePage;
@@ -118,6 +122,30 @@ public void setHeaderDisplayString(String str) {
118122
this.headerDisplayMap.put(HEADER_DISPLAY_STRING, str);
119123
}
120124

125+
public String getHeaderDisplayEnv() {
126+
return headerDisplayMap.get(HEADER_DISPLAY_ENV);
127+
}
128+
129+
public void setHeaderDisplayEnv(String str) {
130+
this.headerDisplayMap.put(HEADER_DISPLAY_ENV, str);
131+
}
132+
133+
public String getHeaderDisplayEnvColor() {
134+
return this.headerDisplayMap.get(HEADER_DISPLAY_ENV_COLOR);
135+
}
136+
137+
public String setHeaderDisplayEnvColor(String str) {
138+
return this.headerDisplayMap.put(HEADER_DISPLAY_ENV_COLOR, str);
139+
}
140+
141+
public String getHeaderDisplayPinnedVersion() {
142+
return headerDisplayMap.get(HEADER_DISPLAY_PINNED_VERSION);
143+
}
144+
145+
public void setHeaderDisplayPinnedVersion(long version) {
146+
this.headerDisplayMap.put(HEADER_DISPLAY_PINNED_VERSION, Long.toString(version));
147+
}
148+
121149
public void addToHeaderDisplayMap(String key, String value) {
122150
headerDisplayMap.put(key, value);
123151
}

hollow-explorer-ui/src/main/java/com/netflix/hollow/explorer/ui/pages/HollowExplorerPage.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ public void render(HttpServletRequest req, HttpServletResponse resp, HollowUISes
5454
ctx.put("headerStringURL", headerDisplayURL);
5555
}
5656

57+
String headerDisplayEnv = ui.getHeaderDisplayEnv();
58+
if (headerDisplayEnv != null) {
59+
ctx.put("headerDisplayEnv", headerDisplayEnv);
60+
String headerDisplayEnvColor = ui.getHeaderDisplayEnvColor();
61+
if (headerDisplayEnvColor != null) {
62+
ctx.put("headerDisplayEnvColor", headerDisplayEnvColor);
63+
}
64+
}
65+
66+
String headerDisplayPinnedVersion = ui.getHeaderDisplayPinnedVersion();
67+
if (headerDisplayPinnedVersion != null) {
68+
ctx.put("headerDisplayPinnedVersion", headerDisplayPinnedVersion);
69+
}
70+
5771
ctx.put("basePath", ui.getBaseURLPath());
5872

5973
ctx.put("esc", new EscapingTool());
@@ -76,5 +90,4 @@ public void render(HttpServletRequest req, HttpServletResponse resp, HollowUISes
7690
* Populates the provided VelocityContext.
7791
*/
7892
protected abstract void setUpContext(HttpServletRequest req, HollowUISession session, VelocityContext ctx);
79-
8093
}

hollow-explorer-ui/src/main/resources/explorer-header.vm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,18 @@
2929
<table>
3030
<tr>
3131
<td class="nav"><a href="$basePath/home">[ Hollow Data Explorer ]</a></td>
32+
#if($headerDisplayEnv)
33+
<td class="nav">[ <span#if($headerDisplayEnvColor != "") style="color: $headerDisplayEnvColor;"#end>$headerDisplayEnv</span> ]</td>
34+
#end
3235
#if($headerDisplayString)
3336
<td class="nav">[ <a target="_blank" href="$headerStringURL">$esc.html($headerDisplayString)</a> ]</td>
3437
#end
3538
#if($stateVersion)
3639
<td class="nav">[ State Version: $stateVersion ]</td>
3740
#end
41+
#if($headerDisplayPinnedVersion)
42+
<td class="nav">[ Explorer is Pinned To: $headerDisplayPinnedVersion ]</td>
43+
#end
3844
## When $type is defined and is not a list, display links to browse
3945
## data and schema for that type.
4046
#if($type && !($type.size() > 0))

0 commit comments

Comments
 (0)