ui (invalid records, zepplin non configured)

This commit is contained in:
Michele Artini 2021-11-03 12:26:59 +01:00
parent caeb3c8ddb
commit 6ec96e2c82
3 changed files with 27 additions and 10 deletions

View File

@ -19,6 +19,7 @@ public class ZeppelinRestController extends AbstractDnetController {
@GetMapping("/zeppelin/templates")
public List<String> getTemplates() throws MDStoreManagerException {
try {
// if (zeppelinClient.get)
return zeppelinClient.listTemplates();
} catch (final Throwable e) {
throw new MDStoreManagerException("Zeppelin is unreachable", e);

View File

@ -75,6 +75,8 @@ public class ZeppelinClient {
public String zeppelinNote(final String note, final MDStoreWithInfo mdstore, final String currentVersionPath) throws MDStoreManagerException {
if (notConfigured()) { throw new MDStoreManagerException("A zeppelin property is empty"); }
final String newName =
StringUtils.join(Arrays.asList(zeppelinNamePrefix, "notes", mdstore.getDatasourceName().replaceAll("/", "-"), mdstore.getApiId()
.replaceAll("/", "-"), note.replaceAll("/", "-"), mdstore.getCurrentVersion().replaceAll("/", "-")), "/");
@ -107,12 +109,17 @@ public class ZeppelinClient {
public List<String> listTemplates() {
final String prefix = zeppelinNamePrefix + "/templates/";
return listNotes().stream()
.map(map -> map.get("name"))
.filter(s -> s.startsWith(prefix))
.map(s -> StringUtils.substringAfter(s, prefix))
.sorted()
.collect(Collectors.toList());
if (notConfigured()) {
return new ArrayList<>();
} else {
return listNotes().stream()
.map(map -> map.get("name"))
.filter(s -> s.startsWith(prefix))
.map(s -> StringUtils.substringAfter(s, prefix))
.sorted()
.collect(Collectors.toList());
}
}
private List<Map<String, String>> listNotes() {
@ -149,8 +156,9 @@ public class ZeppelinClient {
@Scheduled(fixedRate = 12 * 60 * 60 * 1000) // 12 hours
public void cleanExpiredNotes() {
try {
if (notConfigured()) { return; }
try {
// I sort the notes according to the version datestamp (more recent first)
final List<Map<String, String>> notes = listNotes()
.stream()
@ -302,4 +310,8 @@ public class ZeppelinClient {
this.jsessionid = jsessionid;
}
private boolean notConfigured() {
return StringUtils.isAnyBlank(zeppelinBaseUrl, zeppelinLogin, zeppelinPassword, zeppelinNamePrefix);
}
}

View File

@ -124,8 +124,12 @@
<br />
<div class="card mt-4" ng-repeat="rec in records | filter:recordsFilter">
<div class="card-header text-white bg-primary small">{{rec.id}}</div>
<table class="table table-condensed table-striped small">
<div class="card-header text-white bg-primary small">
<span ng-show="rec.id">{{rec.id}}</span>
<span ng-hide="rec.id">the record is unreadable</span>
</div>
<div class="card-body" ng-hide="rec.id">Invalid record format</div>
<table class="table table-condensed table-striped small" ng-show="rec.id">
<tr>
<th class="col-xs-3">Original Id</th>
<td class="col-xs-9">{{rec.originalId}}</td>
@ -147,7 +151,7 @@
</td>
</tr>
</table>
<div class="card-body">
<div class="card-body" ng-show="rec.id">
<span class="badge badge-success float-right">{{rec.encoding}}</span>
<br />
<pre class="small">{{rec.body}}</pre>