aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process/src/main/java/org/sonar/process/ProcessCommands.java
blob: 9a37cd316cba0750f245bc2083ab84003d15b9fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
 * SonarQube
 * Copyright (C) 2009-2016 SonarSource SA
 * mailto:contact AT sonarsource DOT com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package org.sonar.process;

import java.io.File;

/**
 * Process inter-communication to :
 * <ul>
 *   <li>share status of specific process</li>
 *   <li>stop/restart a specific processes</li>
 * </ul>
 *
 * @see DefaultProcessCommands#main(File, int)
 * @see DefaultProcessCommands#secondary(File, int)
 */
public interface ProcessCommands extends AutoCloseable {

  int MAX_PROCESSES = 5;

  boolean isUp();

  /**
   * To be executed by child process to declare that it is done starting
   */
  void setUp();

  boolean isOperational();

  /**
   * To be executed by child process to declare that it is done starting and fully operational.
   *
   * @throws IllegalStateException if {@link #setUp()} has not been called
   */
  void setOperational();

  void ping();

  long getLastPing();

  void setHttpUrl(String s);

  String getHttpUrl();

  /**
   * To be executed by monitor process to ask for child process termination
   */
  void askForStop();

  boolean askedForStop();

  /**
   * To be executed by child process to ask for restart of all child processes
   */
  void askForRestart();

  /**
   * Can be called by child or monitor process to know whether child process asked for restart
   */
  boolean askedForRestart();

  /**
   * To be executed by monitor process to acknowledge restart request from child process.
   */
  void acknowledgeAskForRestart();

  void endWatch();
}