Project

General

Profile

« Previous | Next » 

Revision 33452

Added by Eri Katsari almost 10 years ago

View differences:

modules/uoa-stats-service/trunk/src/main/java/eu/dnetlib/data/statsmanager/Query.java
16 16
    private Logger log = Logger.getLogger(this.getClass());
17 17

  
18 18
    public Query() {
19
    }
19
    };
20 20

  
21
    ;
22

  
23 21
    public Query(String key, Integer dbResult, int cqlResult, boolean qStatus) {
24 22
        this.name = key;
25 23
        this.dbResult = dbResult;
modules/uoa-stats-service/trunk/src/main/java/eu/dnetlib/data/statsmanager/CacheController.java
10 10
import java.net.URL;
11 11
import java.net.URLConnection;
12 12
import java.util.HashMap;
13
import java.util.Map;
13 14

  
14 15

  
15 16
public class CacheController {
......
19 20
    private String httpsPassword;
20 21
    private Logger log = Logger.getLogger(this.getClass());
21 22

  
23

  
22 24
    public CacheController() {
23

  
24 25
    }
25 26

  
26
    public void refreshCache() throws Exception {
27
        executeRemoteScript(this.getActions().get("refreshAll"));
28 27

  
29
    }
28
    public void executeCommand(String cacheURL, String action) throws Exception {
30 29

  
31
    public void refreshNums() throws Exception {
30
        URL url;
31
        if (cacheURL != null && !cacheURL.isEmpty()) {
32 32

  
33
        log.info(this.getActions().get("refreshNums"));
34
        log.info("CacheController : Now refreshing nums...");
35
        executeRemoteScript(this.getActions().get("refreshNums"));
36
    }
33
            log.debug("existing cache url " + this.getActions().get(action));
34
            String actionUrl = this.getActions().get(action).toString();
35
            actionUrl = actionUrl.substring(actionUrl.lastIndexOf("/"), actionUrl.length());
36
            url = new URL(cacheURL + actionUrl);
37 37

  
38
    public void refreshCharts() throws Exception {
39
        executeRemoteScript(this.getActions().get("refreshCharts"));
40
    }
38
        } else {
39
            url = this.actions.get(action);
40
        }
41 41

  
42
    public void promoteCharts() throws Exception {
43
        executeRemoteScript(this.getActions().get("promoteCharts"));
42
        executeRemoteScript(url);
44 43
    }
45 44

  
46
    public void promoteNums() throws Exception {
47
        executeRemoteScript(this.getActions().get("promoteNums"));
48
    }
49 45

  
50
    public void promoteCache() throws Exception {
51
        executeRemoteScript(this.getActions().get("promoteAll"));
52
    }
53

  
54
    public void backup() throws Exception {
55
        executeRemoteScript(this.getActions().get("backup"));
56
    }
57

  
58
    public void migrate() throws Exception {
59
        executeRemoteScript(this.getActions().get("migrate"));
60
    }
61

  
62

  
63
    public void restore() throws Exception {
64
        executeRemoteScript(this.getActions().get("restore"));
65
    }
66

  
67

  
68 46
    private void executeRemoteScript(URL url) throws Exception {
69 47
        try {
70 48

  
71

  
72 49
            Base64Converter converter = new Base64Converter();
73 50
            BufferedReader in = null;
74 51
            if (url.toString().startsWith("https://")) {
......
110 87
        }
111 88
    }
112 89

  
90
/*
91
    public updateCacheURL(String url)
113 92

  
93
    {
94
        HashMap<String, URL> newActions = new HashMap();
95

  
96
        for (e: this.actions.entrySet()) {
97
            newActions.
98

  
99

  
100
        }
101

  
102
    }
103
*/
114 104
    public HashMap<String, URL> getActions() {
115 105
        return actions;
116 106
    }
modules/uoa-stats-service/trunk/src/main/java/eu/dnetlib/data/statsmanager/StatsManager.java
2 2

  
3 3

  
4 4
import org.apache.log4j.Logger;
5
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
6
import eu.dnetlib.enabling.tools.blackboard.BlackboardNotificationHandler;
7
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
8

  
5 9
import org.springframework.transaction.annotation.Transactional;
6 10

  
7 11
import javax.sql.DataSource;
......
22 26
    private Logger log = Logger.getLogger(this.getClass());
23 27

  
24 28
    public StatsManager() {
25

  
26

  
29
 
27 30
    }
28 31

  
29 32

  
......
50 53
    public void updateDBPath(String dbUrl) {
51 54
    }
52 55

  
53
    public void executeCacheAction(String action) throws Exception {
56
    public void executeCacheAction(BlackboardJob job) throws Exception {
54 57

  
55
        if (action.equals("refreshCache")) {
56
            cacheController.refreshCache();
57
        } else if (action.equals("refreshCharts")) {
58
            cacheController.refreshCharts();
59
        } else if (action.equals("refreshNums")) {
60
            log.info("Now refreshing nums...");
61
            cacheController.refreshNums();
62
        } else if (action.equals("promoteShadow")) {
63
            cacheController.promoteCache();
58
        if (job.getAction().equals("refreshCache")) {
59
            log.info("Executing " + job.getAction() + "...");
60
            cacheController.executeCommand(job.getParameters().get("cacheURL"), "refreshAll");
61
        } else if (job.getAction().equals("refreshCharts")) {
62
            log.info("Executing " + job.getAction() + "...");
63
            cacheController.executeCommand(job.getParameters().get("cacheURL"), job.getAction());
64
        } else if (job.getAction().equals("refreshNums")) {
65
            log.info("Executing " + job.getAction() + "...");
66
            cacheController.executeCommand(job.getParameters().get("cacheURL"), job.getAction());
67
        } else if (job.getAction().equals("promoteShadow")) {
68
            log.info("Executing " + job.getAction() + "...");
69
            cacheController.executeCommand(job.getParameters().get("cacheURL"), "promoteAll");
64 70
            this.promoteShadowSchema();
65
        } else if (action.equals("promoteNums")) {
66
            cacheController.promoteNums();
67
        } else if (action.equals("promoteCharts")) {
68
            cacheController.promoteCharts();
69
        } else if (action.equals("promoteCache")) {
70
            cacheController.promoteCache();
71
        } else if (action.equals("restore")) {
72
            cacheController.restore();
73
        } else if (action.equals("migrate")) {
74
            cacheController.migrate();
75
        } else if (action.equals("backup")) {
76
            cacheController.backup();
77
        } else {
78
            log.error("Wrong action given ");
71
        } else if (job.getAction().equals("promoteNums")) {
72
            log.info("Executing " + job.getAction() + "...");
73
            cacheController.executeCommand(job.getParameters().get("cacheURL"), job.getAction());
74
        } else if (job.getAction().equals("promoteCharts")) {
75
            log.info("Executing " + job.getAction() + "...");
76
            cacheController.executeCommand(job.getParameters().get("cacheURL"), job.getAction());
77
        } else if (job.getAction().equals("promoteCache")) {
78
            log.info("Executing " + job.getAction() + "...");
79
            cacheController.executeCommand(job.getParameters().get("cacheURL"), "promoteAll");
80
        } else if (job.getAction().equals("restore")) {
81
            log.info("Executing " + job.getAction() + "...");
82
            cacheController.executeCommand(job.getParameters().get("cacheURL"), job.getAction());
83
        } else if (job.getAction().equals("migrate")) {
84
            log.info("Executing " + job.getAction() + "...");
85
            cacheController.executeCommand(job.getParameters().get("cacheURL"), job.getAction());
86
        } else if (job.getAction().equals("backup")) {
87
            log.info("Executing " + job.getAction() + "...");
88
            cacheController.executeCommand(job.getParameters().get("cacheURL"), job.getAction());
79 89

  
80 90
        }
91
 /* else if (job.getAction().equals("updateCacheURL"))
92
         {
93
            log.info("Executing " + job.getAction() + "...");
94
            cacheController.updateCacheURL(job.getParameters().get("cacheURL"));
95
        }*/
96
        else {
97
            log.error("Wrong action given ");
98
            throw new Exception("Wrong action given ");
99
        }
81 100

  
82 101
    }
83 102

  
modules/uoa-stats-service/trunk/src/main/java/eu/dnetlib/data/statsmanager/StatsManagerServiceBlackboardHandler.java
35 35
                StringWriter sw = new StringWriter();
36 36
                JAXBContext.newInstance(ValidationReport.class).createMarshaller().marshal(report, sw);
37 37
                job.getParameters().put("report", sw.toString());
38
            } else if (action.equals("refreshCache")) {
39
                statsManager.executeCacheAction(action);
40
            } else if (action.equals("refreshNums")) {
41
                logger.info("Now refreshing nums...");
42
                statsManager.executeCacheAction(action);
43
            } else if (action.equals("refreshCharts")) {
44
                statsManager.executeCacheAction(action);
45
            } else if (action.equals("promoteShadow")) {
46
                statsManager.executeCacheAction(action);
47
            } else if (action.equals("promoteNums")) {
48
                statsManager.executeCacheAction(action);
49
            } else if (action.equals("promoteCharts")) {
50
                statsManager.executeCacheAction(action);
51
            } else if (action.equals("promoteCache")) {
52
                statsManager.executeCacheAction(action);
53
            } else if (action.equals("restore")) {
54
                statsManager.executeCacheAction(action);
55
            } else if (action.equals("backup")) {
56
                statsManager.executeCacheAction(action);
57
            } else if (action.equals("migrate")) {
58
                statsManager.executeCacheAction(action);
59
            } else if (action.equals("updateDBPath")) {
60
                statsManager.updateDBPath(job.getParameters().get("dbUrl"));
61 38
            } else {
62
                throw new Exception("Don't know what to do with " + action);
39
                statsManager.executeCacheAction(job);
63 40
            }
64 41

  
65
            getBlackboardHandler().done(job);
66
        } catch (
67
                Exception e
68
                )
69 42

  
70
        {
71
            getBlackboardHandler().failed(job, e);
43
        getBlackboardHandler().done(job);
44
    }
72 45

  
73
            logger.error("Error processing job", e);
74
        }
46
    catch(
47
    Exception e
48
    )
75 49

  
50
    {
51
        getBlackboardHandler().failed(job, e);
52

  
53
        logger.error("Error processing job", e);
76 54
    }
77 55

  
56
}
78 57

  
58

  
79 59
    public StatsManager getStatsManager() {
80 60
        return statsManager;
81 61
    }
modules/uoa-stats-service/trunk/src/main/resources/eu/dnetlib/data/statsmanager/springContext-statsManager.properties
6 6
services.statsManager.db.portalUser = dnet
7 7
services.statsManager.validationQueriesFile = classpath:/eu/dnetlib/data/statsmanager/validationQueries.xml
8 8

  
9
services.statsManager.actions.refreshAll=cacheController?action=refreshAll
10
services.statsManager.actions.refreshNums =cacheController?action=refreshNums
11
services.statsManager.actions.refreshCharts =cacheController?action=refreshCharts
12
services.statsManager.actions.promoteNums =cacheController?action=promoteNums
13
services.statsManager.actions.promoteCharts =cacheController?action=promoteCharts
14
services.statsManager.actions.promoteAll =cacheController?action=promoteAll
15
services.statsManager.actions.backup = cacheController?action=backup
16
services.statsManager.actions.migrate = cacheController?action=migrate
17
services.statsManager.actions.restore =cacheController?action=restore
9
services.statsManager.actions.refreshAll=https://test.openaire.eu/stats/cacheController?action=refreshAll
10
services.statsManager.actions.refreshNums =https://test.openaire.eu/stats/cacheController?action=refreshNums
11
services.statsManager.actions.refreshCharts =https://test.openaire.eu/stats/cacheController?action=refreshCharts
12
services.statsManager.actions.promoteNums =https://test.openaire.eu/stats/cacheController?action=promoteNums
13
services.statsManager.actions.promoteCharts =https://test.openaire.eu/stats/cacheController?action=promoteCharts
14
services.statsManager.actions.promoteAll =https://test.openaire.eu/stats/cacheController?action=promoteAll
15
services.statsManager.actions.backup = https://test.openaire.eu/stats/cacheController?action=backup
16
services.statsManager.actions.migrate = https://test.openaire.eu/stats/cacheController?action=migrate
17
services.statsManager.actions.restore =https://test.openaire.eu/stats/cacheController?action=restore
18 18
services.statsManager.shadowSearchServiceURL=http://duffy.di.uoa.gr:8080/shadowSearch/services/searchWebService
19 19

  
20
services.statsManager.actions.baseURL=https://beta.openaire.eu/stats/
21

  
22

  
20 23
services.statsManager.httpsUsername = eri.katsari
21 24
services.statsManager.httpsPassword = UDxG2ydA
22 25

  

Also available in: Unified diff