Merge pull request #83 from Kingsrook/feature/CE-978-crashing-nodes

CE-978 - Moving from 6 hours to 5 hours for clean hours in addition t…
This commit is contained in:
2024-04-18 09:09:55 -05:00
committed by GitHub
7 changed files with 130 additions and 4 deletions

View File

@ -31,6 +31,7 @@ import java.io.Serializable;
*******************************************************************************/ *******************************************************************************/
public class AsyncJobStatus implements Serializable public class AsyncJobStatus implements Serializable
{ {
private String jobName;
private AsyncJobState state; private AsyncJobState state;
private String message; private String message;
private Integer current; private Integer current;
@ -187,4 +188,36 @@ public class AsyncJobStatus implements Serializable
{ {
this.cancelRequested = cancelRequested; this.cancelRequested = cancelRequested;
} }
/*******************************************************************************
** Getter for jobName
*******************************************************************************/
public String getJobName()
{
return (this.jobName);
}
/*******************************************************************************
** Setter for jobName
*******************************************************************************/
public void setJobName(String jobName)
{
this.jobName = jobName;
}
/*******************************************************************************
** Fluent setter for jobName
*******************************************************************************/
public AsyncJobStatus withJobName(String jobName)
{
this.jobName = jobName;
return (this);
}
} }

View File

@ -0,0 +1,62 @@
/*
* QQQ - Low-code Application Framework for Engineers.
* Copyright (C) 2021-2024. Kingsrook, LLC
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
* contact@kingsrook.com
* https://github.com/Kingsrook/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.kingsrook.qqq.backend.core.actions.async;
import java.util.UUID;
/*******************************************************************************
** subclass designed to be used when we want there to be an instance (so code
** doesn't have to all be null-tolerant), but there's no one who will ever be
** reading the status data, so we don't need to store the object in a
** state provider.
*******************************************************************************/
public class NonPersistedAsyncJobCallback extends AsyncJobCallback
{
private final AsyncJobStatus asyncJobStatus;
/*******************************************************************************
**
*******************************************************************************/
public NonPersistedAsyncJobCallback(UUID jobUUID, AsyncJobStatus asyncJobStatus)
{
super(jobUUID, asyncJobStatus);
this.asyncJobStatus = asyncJobStatus;
}
/*******************************************************************************
**
*******************************************************************************/
@Override
protected void storeUpdatedStatus()
{
///////////////////////////////////////////////////////////////////////////////////////
// noop - cf. base class, which writes to persistence here (our point is, we do not) //
///////////////////////////////////////////////////////////////////////////////////////
}
}

View File

@ -26,6 +26,7 @@ import java.util.UUID;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.kingsrook.qqq.backend.core.actions.async.AsyncJobCallback; import com.kingsrook.qqq.backend.core.actions.async.AsyncJobCallback;
import com.kingsrook.qqq.backend.core.actions.async.AsyncJobStatus; import com.kingsrook.qqq.backend.core.actions.async.AsyncJobStatus;
import com.kingsrook.qqq.backend.core.actions.async.NonPersistedAsyncJobCallback;
import com.kingsrook.qqq.backend.core.context.QContext; import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.exceptions.QInstanceValidationException; import com.kingsrook.qqq.backend.core.exceptions.QInstanceValidationException;
import com.kingsrook.qqq.backend.core.instances.QInstanceValidator; import com.kingsrook.qqq.backend.core.instances.QInstanceValidator;
@ -139,7 +140,7 @@ public class AbstractActionInput
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// don't return null here (too easy to NPE). instead, if someone wants one of these, create one and give it to them. // // don't return null here (too easy to NPE). instead, if someone wants one of these, create one and give it to them. //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
asyncJobCallback = new AsyncJobCallback(UUID.randomUUID(), new AsyncJobStatus()); asyncJobCallback = new NonPersistedAsyncJobCallback(UUID.randomUUID(), new AsyncJobStatus().withJobName(getClass().getSimpleName()));
} }
return asyncJobCallback; return asyncJobCallback;
} }

View File

@ -30,6 +30,7 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
import com.kingsrook.qqq.backend.core.actions.async.AsyncJobCallback; import com.kingsrook.qqq.backend.core.actions.async.AsyncJobCallback;
import com.kingsrook.qqq.backend.core.actions.async.AsyncJobStatus; import com.kingsrook.qqq.backend.core.actions.async.AsyncJobStatus;
import com.kingsrook.qqq.backend.core.actions.async.NonPersistedAsyncJobCallback;
import com.kingsrook.qqq.backend.core.actions.processes.QProcessCallback; import com.kingsrook.qqq.backend.core.actions.processes.QProcessCallback;
import com.kingsrook.qqq.backend.core.context.QContext; import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.model.actions.AbstractActionInput; import com.kingsrook.qqq.backend.core.model.actions.AbstractActionInput;
@ -450,7 +451,7 @@ public class RunBackendStepInput extends AbstractActionInput
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// avoid NPE in case we didn't have one of these! create a new one... // // avoid NPE in case we didn't have one of these! create a new one... //
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
asyncJobCallback = new AsyncJobCallback(UUID.randomUUID(), new AsyncJobStatus()); asyncJobCallback = new NonPersistedAsyncJobCallback(UUID.randomUUID(), new AsyncJobStatus().withJobName(processName + "." + stepName));
} }
return (asyncJobCallback); return (asyncJobCallback);
} }

View File

@ -46,8 +46,8 @@ public class InMemoryStateProvider implements StateProviderInterface
private final Map<AbstractStateKey, Object> map; private final Map<AbstractStateKey, Object> map;
private static int jobPeriodSeconds = 60 * 60; // 1 hour private static int jobPeriodSeconds = 60 * 30; // 30 minutes
private static int cleanHours = 6; private static int cleanHours = 5;
private static int jobInitialDelay = 60 * 60 * cleanHours; private static int jobInitialDelay = 60 * 60 * cleanHours;
@ -151,6 +151,18 @@ public class InMemoryStateProvider implements StateProviderInterface
/*******************************************************************************
** Get the current status
*
*******************************************************************************/
@Override
public String status()
{
return ("InMemoryStateProvider map size: " + map.size());
}
/******************************************************************************* /*******************************************************************************
** Clean entries that started before the given Instant ** Clean entries that started before the given Instant
* *

View File

@ -59,6 +59,11 @@ public interface StateProviderInterface
*******************************************************************************/ *******************************************************************************/
void remove(AbstractStateKey key); void remove(AbstractStateKey key);
/*******************************************************************************
** Get the current status
*******************************************************************************/
String status();
/******************************************************************************* /*******************************************************************************
** Clean entries that started before the given Instant ** Clean entries that started before the given Instant
*******************************************************************************/ *******************************************************************************/

View File

@ -128,6 +128,18 @@ public class TempFileStateProvider implements StateProviderInterface
/*******************************************************************************
** Get the current status
*
*******************************************************************************/
@Override
public String status()
{
return ("TempFileStateProvider status not supported");
}
/******************************************************************************* /*******************************************************************************
** Clean entries that started before the given Instant ** Clean entries that started before the given Instant
*******************************************************************************/ *******************************************************************************/