This repository has been archived by the owner on Sep 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # server/src/main/java/org/tango/server/servant/DeviceImpl.java
- Loading branch information
Showing
3 changed files
with
371 additions
and
716 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 91 additions & 77 deletions
168
server/src/main/java/org/tango/server/monitoring/DeviceMonitoring.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,91 @@ | ||
/** | ||
* Copyright (C) : 2012 | ||
* | ||
* Synchrotron Soleil | ||
* L'Orme des merisiers | ||
* Saint Aubin | ||
* BP48 | ||
* 91192 GIF-SUR-YVETTE CEDEX | ||
* | ||
* This file is part of Tango. | ||
* | ||
* Tango 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. | ||
* | ||
* Tango 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 Tango. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.tango.server.monitoring; | ||
|
||
import org.tango.server.history.DeviceBlackBox; | ||
|
||
import fr.esrf.Tango.ClntIdent; | ||
import fr.esrf.Tango.DevFailed; | ||
import fr.esrf.Tango.DevSource; | ||
|
||
public class DeviceMonitoring { | ||
private static final String SEPARATOR = " - "; | ||
private final String deviceName; | ||
private final DeviceBlackBox blackbox; | ||
private final TangoStats monitoring; | ||
|
||
public DeviceMonitoring(final String deviceName) { | ||
this.deviceName = deviceName; | ||
blackbox = new DeviceBlackBox(); | ||
monitoring = TangoStats.getInstance(); | ||
} | ||
|
||
public long startRequest(final String request) { | ||
blackbox.insertInblackBox(request); | ||
return monitoring.addRequest(deviceName + SEPARATOR + request); | ||
} | ||
|
||
public long startRequest(final String request, final ClntIdent clt) { | ||
blackbox.insertInblackBox(request, clt); | ||
return monitoring.addRequest(deviceName + SEPARATOR + request); | ||
} | ||
|
||
public long startRequest(final String request, final DevSource devSource) { | ||
blackbox.insertInblackBox(request, devSource); | ||
return monitoring.addRequest(deviceName + SEPARATOR + request); | ||
} | ||
|
||
public long startRequest(final String request, final DevSource devSource, final ClntIdent clt) { | ||
blackbox.insertInblackBox(request, devSource, clt); | ||
return monitoring.addRequest(deviceName + SEPARATOR + request); | ||
} | ||
|
||
public void addError() { | ||
monitoring.addError(); | ||
} | ||
|
||
public void endRequest(final long id) { | ||
monitoring.endRequest(id); | ||
} | ||
|
||
public String[] getBlackBox(final int size) throws DevFailed { | ||
return blackbox.toArray(size); | ||
} | ||
|
||
} | ||
/** | ||
* Copyright (C) : 2012 | ||
* | ||
* Synchrotron Soleil | ||
* L'Orme des merisiers | ||
* Saint Aubin | ||
* BP48 | ||
* 91192 GIF-SUR-YVETTE CEDEX | ||
* | ||
* This file is part of Tango. | ||
* | ||
* Tango 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. | ||
* | ||
* Tango 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 Tango. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.tango.server.monitoring; | ||
|
||
import fr.esrf.Tango.ClntIdent; | ||
import fr.esrf.Tango.DevFailed; | ||
import fr.esrf.Tango.DevSource; | ||
import org.tango.server.history.DeviceBlackBox; | ||
|
||
import java.io.Closeable; | ||
|
||
public class DeviceMonitoring { | ||
private static final String SEPARATOR = " - "; | ||
private final String deviceName; | ||
private final DeviceBlackBox blackbox; | ||
private final TangoStats monitoring; | ||
|
||
public DeviceMonitoring(final String deviceName) { | ||
this.deviceName = deviceName; | ||
blackbox = new DeviceBlackBox(); | ||
monitoring = TangoStats.getInstance(); | ||
} | ||
|
||
public Request startRequest(final String request) { | ||
blackbox.insertInblackBox(request); | ||
return new Request(deviceName + SEPARATOR + request); | ||
} | ||
|
||
public Request startRequest(final String request, final ClntIdent clt) { | ||
blackbox.insertInblackBox(request, clt); | ||
return new Request(deviceName + SEPARATOR + request); | ||
} | ||
|
||
public Request startRequest(final String request, final DevSource devSource) { | ||
blackbox.insertInblackBox(request, devSource); | ||
return new Request(deviceName + SEPARATOR + request); | ||
} | ||
|
||
public Request startRequest(final String request, final DevSource devSource, final ClntIdent clt) { | ||
blackbox.insertInblackBox(request, devSource, clt); | ||
return new Request(deviceName + SEPARATOR + request); | ||
} | ||
|
||
public void addError() { | ||
monitoring.addError(); | ||
} | ||
|
||
public void endRequest(final long id) { | ||
monitoring.endRequest(id); | ||
} | ||
|
||
public String[] getBlackBox(final int size) throws DevFailed { | ||
return blackbox.toArray(size); | ||
} | ||
|
||
public class Request implements Closeable { | ||
public final long id; | ||
|
||
Request(String request) { | ||
this.id = monitoring.addRequest(request); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
monitoring.endRequest(id); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.