Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
Cherry-pick 45b585a
Browse files Browse the repository at this point in the history
# Conflicts:
#	server/src/main/java/org/tango/server/servant/DeviceImpl.java
  • Loading branch information
Ingvord committed Sep 2, 2019
1 parent 96af9aa commit ac78fed
Show file tree
Hide file tree
Showing 3 changed files with 371 additions and 716 deletions.
13 changes: 6 additions & 7 deletions common/src/main/java/org/tango/utils/DevFailedUtils.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package org.tango.utils;

import java.io.PrintWriter;
import java.io.StringWriter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import fr.esrf.Tango.DevError;
import fr.esrf.Tango.DevFailed;
import fr.esrf.Tango.ErrSeverity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.PrintWriter;
import java.io.StringWriter;

public final class DevFailedUtils {
private static final String TANGO_ERROR = "TANGO_ERROR";
Expand Down Expand Up @@ -62,7 +61,7 @@ public static DevError[] buildDevError(final String reason, final String desc, f
return err;
}

public static DevFailed newDevFailed(final Throwable origin) throws DevFailed {
public static DevFailed newDevFailed(final Throwable origin) {
final DevError[] err = new DevError[1];
err[0] = new DevError();
err[0].desc = origin.getClass().getCanonicalName();
Expand Down
168 changes: 91 additions & 77 deletions server/src/main/java/org/tango/server/monitoring/DeviceMonitoring.java
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);
}
}

}
Loading

0 comments on commit ac78fed

Please sign in to comment.