public LogChannelFileWriterBuffer getLogChannelFileWriterBuffer( String id ) { for ( String bufferId : this.fileWriterBuffers.keySet() ) { if ( getLogChannelChildren( bufferId ).contains( id ) ) { return this.fileWriterBuffers.get( bufferId ); } } return null; }
public List<String> getLogChannelChildren( String parentLogChannelId ) { if ( parentLogChannelId == null ) { return null; } List<String> list = getLogChannelChildren( new ArrayList<String>(), parentLogChannelId ); list.add( parentLogChannelId ); return list; }
public void removeLogChannelFileWriterBuffer( String id ) { Set<String> bufferIds = this.fileWriterBuffers.keySet(); for ( String bufferId : bufferIds ) { if ( getLogChannelChildren( id ).contains( bufferId ) ) { this.fileWriterBuffers.remove( bufferId ); } } }
protected Set<String> getLogChannelFileWriterBufferIds() { Set<String> bufferIds = this.fileWriterBuffers.keySet(); // Changed to a set as a band-aid for PDI-16658. This stuff really should be done // using a proper LRU cache. Set<String> ids = new HashSet<>(); for ( String id : bufferIds ) { ids.addAll( getLogChannelChildren( id ) ); } ids.addAll( bufferIds ); return ids; }
private List<String> getLogChannelChildren( List<String> children, String parentLogChannelId ) { synchronized ( this.syncObject ) { List<String> list = this.childrenMap.get( parentLogChannelId ); if ( list == null ) { // Don't do anything, just return the input. return children; } Iterator<String> kids = list.iterator(); while ( kids.hasNext() ) { String logChannelId = kids.next(); // Add the children recursively getLogChannelChildren( children, logChannelId ); // Also add the current parent children.add( logChannelId ); } } return children; }
public void removeIncludingChildren( String logChannelId ) { synchronized ( this.map ) { List<String> children = getLogChannelChildren( logChannelId ); for ( String child : children ) { this.map.remove( child ); } this.map.remove( logChannelId ); removeOrphans(); } }
/** * @param parentLogChannelId the parent log channel ID to grab * @param includeGeneral include general log lines * @param from * @param to * @return */ public List<KettleLoggingEvent> getLogBufferFromTo( String parentLogChannelId, boolean includeGeneral, int from, int to ) { // Typically, the log channel id is the one from the transformation or job running currently. // However, we also want to see the details of the steps etc. // So we need to look at the parents all the way up if needed... // List<String> childIds = loggingRegistry.getLogChannelChildren( parentLogChannelId ); return getLogBufferFromTo( childIds, includeGeneral, from, to ); }
public static List<MetricsDuration> getAllDurations( String parentLogChannelId ) { List<MetricsDuration> durations = new ArrayList<MetricsDuration>(); List<String> logChannelIds = LoggingRegistry.getInstance().getLogChannelChildren( parentLogChannelId ); for ( String logChannelId : logChannelIds ) { LoggingObjectInterface object = LoggingRegistry.getInstance().getLoggingObject( logChannelId ); if ( object != null ) { durations.addAll( getDurations( logChannelId ) ); } } return durations; }
@Override public void eventAdded( KettleLoggingEvent event ) { try { Object messageObject = event.getMessage(); if ( messageObject instanceof LogMessage ) { boolean logToFile = false; if ( logChannelId == null ) { logToFile = true; } else { LogMessage message = (LogMessage) messageObject; // This should be fast enough cause cached. List<String> logChannelChildren = LoggingRegistry.getInstance().getLogChannelChildren( logChannelId ); // This could be non-optimal, consider keeping the list sorted in the logging registry logToFile = Const.indexOfString( message.getLogChannelId(), logChannelChildren ) >= 0; } if ( logToFile ) { String logText = layout.format( event ); outputStream.write( logText.getBytes() ); outputStream.write( Const.CR.getBytes() ); } } } catch ( Exception e ) { exception = new KettleException( "Unable to write to logging event to file '" + filename + "'", e ); } }
/** * Gets the logging hierarchy. * * @return the logging hierarchy */ public List<LoggingHierarchy> getLoggingHierarchy() { List<LoggingHierarchy> hierarchy = new ArrayList<>(); List<String> childIds = LoggingRegistry.getInstance().getLogChannelChildren( getLogChannelId() ); for ( String childId : childIds ) { LoggingObjectInterface loggingObject = LoggingRegistry.getInstance().getLoggingObject( childId ); if ( loggingObject != null ) { hierarchy.add( new LoggingHierarchy( getLogChannelId(), batchId, loggingObject ) ); } } return hierarchy; }
/** * Gets the logging hierarchy. * * @return the logging hierarchy */ public List<LoggingHierarchy> getLoggingHierarchy() { List<LoggingHierarchy> hierarchy = new ArrayList<LoggingHierarchy>(); List<String> childIds = LoggingRegistry.getInstance().getLogChannelChildren( getLogChannelId() ); for ( String childId : childIds ) { LoggingObjectInterface loggingObject = LoggingRegistry.getInstance().getLoggingObject( childId ); if ( loggingObject != null ) { hierarchy.add( new LoggingHierarchy( getLogChannelId(), batchId, loggingObject ) ); } } return hierarchy; }
/** * Discard all the lines for the specified log channel id AND all the children. * * @param parentLogChannelId * the parent log channel id to be removed along with all its children. */ public static void discardLines( String parentLogChannelId, boolean includeGeneralMessages ) { LoggingRegistry registry = LoggingRegistry.getInstance(); MetricsRegistry metricsRegistry = MetricsRegistry.getInstance(); List<String> ids = registry.getLogChannelChildren( parentLogChannelId ); // Remove all the rows for these ids // LoggingBuffer bufferAppender = getInstance().appender; // int beforeSize = bufferAppender.size(); for ( String id : ids ) { // Remove it from the central log buffer // bufferAppender.removeChannelFromBuffer( id ); // Also remove the item from the registry. // registry.getMap().remove( id ); metricsRegistry.getSnapshotLists().remove( id ); metricsRegistry.getSnapshotMaps().remove( id ); } // Now discard the general lines if this is required // if ( includeGeneralMessages ) { bufferAppender.removeGeneralMessages(); } }
db.setCommit( logCommitSize ); List<String> logChannelIds = LoggingRegistry.getInstance().getLogChannelChildren( getLogChannelId() ); for ( String logChannelId : logChannelIds ) { Queue<MetricsSnapshotInterface> snapshotList =
LoggingObjectInterface loggingObject = LoggingRegistry.getInstance().getLoggingObject( logChannelId ); String parentLogChannelId = loggingObject.getParent().getLogChannelId(); List<String> logChannelChildren = LoggingRegistry.getInstance().getLogChannelChildren( parentLogChannelId ); int childIndex = Const.indexOfString( log.getLogChannelId(), logChannelChildren ); if ( log.isDebug() ) {