use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project DigitalMediaServer by DigitalMediaServer.
the class ChromecastPlayer method startPoll.
public void startPoll() {
Runnable r = new Runnable() {
@Override
public void run() {
for (; ; ) {
try {
Thread.sleep(1000);
Status s1 = api.getStatus();
if (s1 == null || !s1.isAppRunning(MediaPlayer)) {
continue;
}
MediaStatus status = api.getMediaStatus();
if (status == null) {
continue;
}
state.playback = translateState(status.playerState);
Media m = status.media;
if (m != null) {
if (m.url != null) {
state.uri = status.media.url;
}
if (m.duration != null) {
state.duration = StringUtil.convertTimeToString(status.media.duration, "%02d:%02d:%02.0f");
}
}
state.position = StringUtil.convertTimeToString(status.currentTime, "%02d:%02d:%02.0f");
if (status.volume != null) {
state.volume = status.volume.level.intValue();
state.mute = status.volume.muted;
}
alert();
} catch (InterruptedException | IOException e) {
LOGGER.debug("Bad chromecast mediastate " + e);
}
}
}
};
poller = new Thread(r);
poller.start();
}
use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project data-prepper by opensearch-project.
the class OTelProtoHelperTest method testStatusAttributes.
@Test
public void testStatusAttributes() {
final Status st1 = Status.newBuilder().setCode(Status.StatusCode.STATUS_CODE_ERROR).setMessage("Some message").build();
final Status st2 = Status.newBuilder().setMessage("error message").build();
final Status st3 = Status.newBuilder().setCode(Status.StatusCode.STATUS_CODE_UNSET).build();
final Status st4 = Status.newBuilder().build();
assertThat(OTelProtoHelper.getSpanStatusAttributes(st1).size() == 2).isTrue();
assertThat(Status.StatusCode.forNumber((Integer) OTelProtoHelper.getSpanStatusAttributes(st1).get(OTelProtoHelper.STATUS_CODE)).equals(st1.getCode())).isTrue();
assertThat(OTelProtoHelper.getSpanStatusAttributes(st1).get(OTelProtoHelper.STATUS_MESSAGE).equals(st1.getMessage())).isTrue();
assertThat(OTelProtoHelper.getSpanStatusAttributes(st2).size() == 2).isTrue();
assertThat(Status.StatusCode.forNumber((Integer) OTelProtoHelper.getSpanStatusAttributes(st2).get(OTelProtoHelper.STATUS_CODE)).equals(st2.getCode())).isTrue();
assertThat(OTelProtoHelper.getSpanStatusAttributes(st3).size() == 1).isTrue();
assertThat(Status.StatusCode.forNumber((Integer) OTelProtoHelper.getSpanStatusAttributes(st3).get(OTelProtoHelper.STATUS_CODE)).equals(st3.getCode())).isTrue();
assertThat(OTelProtoHelper.getSpanStatusAttributes(st4).size() == 1).isTrue();
assertThat(Status.StatusCode.forNumber((Integer) OTelProtoHelper.getSpanStatusAttributes(st4).get(OTelProtoHelper.STATUS_CODE)).equals(st4.getCode())).isTrue();
}
use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project openhab-addons by openhab.
the class ChromecastCommander method handleRefresh.
public void handleRefresh() {
if (!chromeCast.isConnected()) {
scheduler.cancelRefresh();
scheduler.scheduleConnect();
return;
}
Status status;
try {
status = chromeCast.getStatus();
statusUpdater.processStatusUpdate(status);
if (status == null) {
scheduler.cancelRefresh();
}
} catch (IOException ex) {
logger.debug("Failed to request status: {}", ex.getMessage());
statusUpdater.updateStatus(ThingStatus.OFFLINE, COMMUNICATION_ERROR, ex.getMessage());
scheduler.cancelRefresh();
return;
}
try {
if (status != null && status.getRunningApp() != null) {
MediaStatus mediaStatus = chromeCast.getMediaStatus();
statusUpdater.updateMediaStatus(mediaStatus);
if (mediaStatus != null && mediaStatus.playerState == MediaStatus.PlayerState.IDLE && mediaStatus.idleReason != null && mediaStatus.idleReason != MediaStatus.IdleReason.INTERRUPTED) {
stopMediaPlayerApp();
}
}
} catch (IOException ex) {
logger.debug("Failed to request media status with a running app: {}", ex.getMessage());
// We were just able to request status, so let's not put the device OFFLINE.
}
}
use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project geotoolkit by Geomatys.
the class WPS2Process method checkResult.
/**
* A Function to ensure response object is success or failure. Otherwise, we request continually status until
* we reach a result.
*
* @param response The execute response given by service.
*/
private Result checkResult(Object response) throws IOException, JAXBException, InterruptedException, ProcessException {
if (response instanceof ExceptionResponse) {
final ExceptionResponse report = (ExceptionResponse) response;
throw new ProcessException("Exception when executing the process.", this, report.toException());
} else if (response instanceof StatusInfo) {
final StatusInfo statusInfo = (StatusInfo) response;
Status status = statusInfo.getStatus();
jobId = statusInfo.getJobID();
if (Status.SUCCEEDED.equals(status)) {
fireProgressing("WPS remote process has been successfully executed", 100f, false);
return null;
} else if (Status.FAILED.equals(status)) {
throw new ProcessException("Process failed", this);
} else if (Status.DISMISS.equals(status)) {
throw new DismissProcessException("WPS remote process has been canceled", this);
} else if (Status.ACCEPTED.equals(status)) {
// Initial status
fireProgressing("Process accepted: " + jobId, 0, false);
} else {
// Running
final Integer progress = statusInfo.getPercentCompleted();
// Not in the standard
String message = statusInfo.getMessage();
if (message == null || (message = message.trim()).isEmpty()) {
message = status.name();
}
fireProgressing(message, progress == null ? Float.NaN : progress, false);
}
// loop until we have an answer
Object tmpResponse;
// TODO : make timelapse configurable
int timeLapse = 3000;
// we tolerate a few unmarshalling or IO errors, the servers behave differentely
// and may not offer the result file right from the start
int failCount = 0;
while (true) {
stopIfDismissed();
synchronized (this) {
wait(timeLapse);
}
try {
tmpResponse = getStatus();
failCount = 0;
} catch (UnmarshalException | IOException ex) {
if (failCount < 5 && !isDimissed()) {
failCount++;
continue;
} else if (isDimissed()) {
throw new DismissProcessException("WPS remote process has been canceled", this);
} else {
// happenning so we consider the process failed
throw ex;
}
}
if (tmpResponse instanceof StatusInfo) {
final StatusInfo statInfo = (StatusInfo) tmpResponse;
status = statInfo.getStatus();
if (Status.SUCCEEDED.equals(status)) {
fireProgressing("WPS remote process has been successfully executed", 100f, false);
return null;
} else if (Status.FAILED.equals(status)) {
throw new ProcessException("Process failed", this);
} else if (Status.DISMISS.equals(status)) {
throw new DismissProcessException("WPS remote process has been canceled", this);
}
// Not in the standard
String message = statusInfo.getMessage();
if (message == null || (message = message.trim()).isEmpty()) {
message = status.name();
}
final Integer percentCompleted = statInfo.getPercentCompleted();
if (!Objects.equals(message, lastMessage) || !Objects.equals(percentCompleted, lastProgress)) {
lastMessage = message;
lastProgress = percentCompleted;
fireProgressing(lastMessage, lastProgress, false);
}
} else if (tmpResponse instanceof ExceptionResponse) {
final ExceptionResponse report = (ExceptionResponse) tmpResponse;
throw new ProcessException("Exception when executing the process.", this, report.toException());
}
}
} else if (response instanceof Result) {
final Result result = checkLegacyResult((Result) response);
if (result.getJobID() != null) {
jobId = result.getJobID();
}
return result;
} else {
throw new ProcessException("Unexpected response " + response, this);
}
}
use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project theta by ftsrg.
the class Z3Solver method check.
@Override
public SolverStatus check() {
final Status z3Status = z3Solver.check();
status = transformStatus(z3Status);
return status;
}
Aggregations