private boolean sameType( RemoteSource source1, RemoteSource source2 ) { return source1.getModelType() == source2.getModelType(); } }
public StopMessage build() { return new StopMessage( requestUUID, reasonPhrase, result, safeStop ); } }
public static Builder builder() { return new Builder(); }
@Override public void safeStop() { try { getDaemonEndpoint().sendMessage( StopMessage.builder() .reasonPhrase( "User Request" ) .safeStop( true ) .build() ); //stopped but still running will yield status Halting getSteps().stream().map( stepMetaDataCombi -> stepMetaDataCombi.step ) .filter( stepInterface -> stepInterface.getInputRowSets().isEmpty() ) .forEach( step -> step.setStopped( true ) ); Executors.newSingleThreadExecutor().submit( () -> { waitUntilFinished(); finishProcess( true ); } ); } catch ( KettleException e ) { getLogChannel().logDebug( e.getMessage(), e ); } }
public static MetricsEvent getMetricEvents( String operationID ) { return new MetricsEvent( new RemoteSource( ModelType.OPERATION, operationID ), null ); } }
@Override public int hashCode() { int result = 0; if ( source instanceof RemoteSource ) { result = this.getClass().getName().hashCode(); result = 31 * result + ( ( (RemoteSource) source ).getModelType() != null ? ( (RemoteSource) source ).getModelType().toString().hashCode() : 0 ); result = 31 * result + ( ( (RemoteSource) source ).getId() != null ? ( (RemoteSource) source ).getId().hashCode() : 0 ); } else { result = source.getId().hashCode(); result = 31 * result + data.hashCode(); } return result; } }
@Override public boolean matches( Object o ) { return ((StopMessage) o).isSafeStop(); }
public ExecutionException( Throwable throwable ) { super( throwable.getMessage() ); this.exceptionType = throwable.getClass().getName(); setStackTrace( throwable.getStackTrace() ); }
/** * Encode the given AEL Message object into a String. * * @param object the Message object being encoded. * @return the encoded object as a string. */ @Override public String encode( Message object ) throws EncodeException { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream( baos ); oos.writeObject( object ); oos.close(); return EncodeUtil.encodeBase64Zipped( baos.toByteArray() ); } catch ( Exception e ) { throw new RuntimeException( "Unexpected error trying to encode object.", e ); } }
/** * Decode the given String into an AEL Message object. * * @param string string to be decoded. * @return the decoded message as an Message object. */ @Override public Message decode( String string ) throws DecodeException { try { byte[] data = EncodeUtil.decodeBase64Zipped( string ); InputStream is = new ByteArrayInputStream( data ); ObjectInputStream ois = new ObjectInputStream( is ); Object o = ois.readObject(); ois.close(); return (Message) o; } catch ( Exception e ) { throw new RuntimeException( "Unexpected error trying to decode object.", e ); } }
/** * Send a execution request message. */ public void sendMessage( ExecutionRequest request ) throws KettleException { sessionValid(); try { request.setReuseSparkContext( reuseSparkContext ); this.userSession.getBasicRemote().sendObject( request ); } catch ( Exception e ) { throw new KettleException( e ); } }
@Test public void testStopMessageFireEvent() throws KettleException { addHandlers( new StopMessage( "" ), messageEventHandler, messageEventHandler2 ); StopMessage msg = new StopMessage( "User request" ); messageEventService.fireEvent( msg ); verify( messageEventHandler ).execute( msg ); verify( messageEventHandler2 ).execute( msg ); }
public static LogEvent getOperationLogEvent( String operationID ) { return new LogEvent( new RemoteSource( ModelType.OPERATION, operationID ), null ); }
private boolean isTrans( RemoteSource source1 ) { return source1.getModelType() == ModelType.TRANSFORMATION; }
@Override public void stopAll() { try { cancelling = true; getDaemonEndpoint().sendMessage( new StopMessage( getErrors() == 0 ? "User Request" : "Error reported" ) ); if ( getErrors() == 0 ) { waitUntilFinished(); finishProcess( true ); } } catch ( KettleException e ) { getLogChannel().logDebug( e.getMessage() ); } finally { cancelling = false; } }
public static DataEvent getOperationRowEvent( String operationID ) { return new DataEvent( new RemoteSource( ModelType.OPERATION, operationID ), null ); }
public static StatusEvent getOperationStatusEvent( String operationID ) { return new StatusEvent( new RemoteSource( ModelType.OPERATION, operationID ), null ); }
@Test public void testTransformationFireEvent() throws Exception { addHandlers( transformationMessageEvent, messageEventHandler, messageEventHandler2 ); LogEvent logEvent = new LogEvent<>( new RemoteSource( ModelType.TRANSFORMATION, "Operation_ID" ), logEntry ); messageEventService.fireEvent( logEvent ); verify( messageEventHandler ).execute( logEvent ); verify( messageEventHandler2 ).execute( logEvent ); }
@Test public void testOperationFireEvent() throws KettleException { addHandlers( operationMessageEvent, messageEventHandler, messageEventHandler2 ); LogEvent logEvent = new LogEvent<>( new RemoteSource( ModelType.OPERATION, "Operation_ID" ), logEntry ); messageEventService.fireEvent( logEvent ); verify( messageEventHandler ).execute( logEvent ); verify( messageEventHandler2 ).execute( logEvent ); }