Commit 3d9fe230 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Automatic reload of node states (#3827); bugfix of missing size after upload and other minor issues

parent 8e505442
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -48,8 +48,8 @@ public class NodeInfo {
        this.sticky = isSticky(node);
        this.busy = isBusy(node);
        this.listOfFiles = isListOfFiles(node);
        this.writable = NodeUtils.checkIfWritable(node, user.getName(), user.getGroups());
        this.deletable = writable && !sticky;
        this.writable = NodeUtils.checkIfWritable(node, user.getName(), user.getGroups()) && !busy;
        this.deletable = writable && !sticky && !asyncTrans;
    }

    private String getPath(Node node) {
+9 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
import { mapState } from 'vuex'
import TopMenu from './components/TopMenu.vue'
import client from 'api-client'
import nodesReloader from './nodesReloader.js'

export default {
  name: 'App',
@@ -34,6 +35,13 @@ export default {
    this.$store.dispatch('loadJobs');
    this.$store.dispatch('loadUserInfo');
    setInterval(client.keepalive, 60000);
    setInterval(nodesReloader.checkNodes, 1000);
    let self = this;
    setInterval(function() {
      if (self.$router.currentRoute.path !== '/jobs') {
        self.$store.dispatch('checkJobs');
      }
    }, 1000);
  }
}
</script>
+4 −4
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ function escapePath(path) {
}

export default {
  getNode(path) {
  getNode(path, loading) {
    let url = BASE_API_URL + 'nodes/' + escapePath(path);
    return apiRequest({
      method: 'GET',
@@ -55,7 +55,7 @@ export default {
      headers: {
        'Cache-Control': 'no-cache'
      }
    }, true, true);
    }, (typeof loading !== 'undefined') ? loading : true, true);
  },
  loadJobs() {
    let url = BASE_API_URL + 'jobs';
@@ -124,11 +124,11 @@ export default {
  uploadFile(url, file) {
    let formData = new FormData();
    formData.append('file', file);
    axios.put(url, formData, {
    return axios.put(url, formData, {
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
    });
  },
  deleteNodes(paths) {
    let url = BASE_API_URL + 'delete';
+1 −0
Original line number Diff line number Diff line
<template>
<div>
  <b-button variant="primary" class="float-right" @click="loadJobs">Reload</b-button>
  <h3>Async recall jobs</h3>
  <table class="table b-table table-striped table-hover">
    <thead>
+49 −0
Original line number Diff line number Diff line
import store from './store.js'
import client from 'api-client'

let lastResultTime = null;
let times = 0;

function checkNodes() {
  let busyNodes = document.getElementsByClassName('node-busy').length > 0;
  let jobsInProgress = store.state.jobs.filter(j => j.phase === 'EXECUTING').length > 0;
  if (!busyNodes && !jobsInProgress) {
    // reset state
    lastResultTime = null;
    times = 0;
    return;
  }
  if (lastResultTime !== null) {
    // first 10 times check every second, then check every ten seconds
    let offset = times < 10 ? 1000 : 10000;
    let now = new Date().getTime();
    if (now - lastResultTime < offset) {
      return;
    }
  }

  if (!store.state.nodesLoading) {
    let path = store.state.path;
    store.commit('setNodesLoading', true);
    client.getNode(path, false)
      .then(res => {
        // check that path didn't change in meantime by user action
        if (path === store.state.path) {
          let resHasBusyNodes = res.htmlTable.includes('node-busy');
          if ((!busyNodes && resHasBusyNodes) || (busyNodes && !resHasBusyNodes)) {
            store.dispatch('setNodes', res);
          } else {
            times++;
            lastResultTime = new Date().getTime();
          }
        }
      })
      .finally(() => {
        store.commit('setNodesLoading', false);
      });
  }
}

export default {
  checkNodes
}
Loading