-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c29748
commit ea7711c
Showing
6 changed files
with
88 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,23 +20,21 @@ | |
|
||
import com.qlangtech.tis.coredefine.module.action.TargetResName; | ||
import com.qlangtech.tis.datax.TimeFormat; | ||
import com.qlangtech.tis.datax.job.JobResName.IJobExec; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.function.Consumer; | ||
|
||
/** | ||
* @author: 百岁([email protected]) | ||
* @create: 2023-12-29 10:01 | ||
**/ | ||
public abstract class JobResName<T, EXEC extends IJobExec<T>> extends TargetResName { | ||
private final EXEC jobExec; | ||
public abstract class JobResName<T> extends TargetResName { | ||
// private final EXEC jobExec; | ||
private static final Logger logger = LoggerFactory.getLogger(JobResName.class); | ||
|
||
public JobResName(String name, EXEC jobExec) { | ||
public JobResName(String name //, EXEC jobExec | ||
) { | ||
super(name); | ||
this.jobExec = jobExec; | ||
// this.jobExec = jobExec; | ||
} | ||
|
||
|
||
|
@@ -70,7 +68,7 @@ public final void execSubJob(T t) throws Exception { | |
boolean success = false; | ||
try { | ||
sse.info(this.getName(), TimeFormat.getCurrentTimeStamp(), "〇〇 start to publish " + this.getResourceType() + "'" + this.getName() + "'"); | ||
this.execute(sse, t, this.jobExec); | ||
this.execute(sse, t); | ||
success = true; | ||
sse.info(this.getName(), TimeFormat.getCurrentTimeStamp(), "✔✔ successful to publish " + this.getResourceType() + "'" + this.getName() + "'"); | ||
} catch (Exception e) { | ||
|
@@ -84,7 +82,7 @@ public final void execSubJob(T t) throws Exception { | |
} | ||
} | ||
|
||
protected abstract void execute(SSERunnable sse, T t, EXEC jobExec) throws Exception; | ||
protected abstract void execute(SSERunnable sse, T t) throws Exception; | ||
// if (jobExec instanceof SubJobExec) { | ||
// ((OwnerJobExec) jobExec).accept(t); | ||
// } else { | ||
|
@@ -94,15 +92,12 @@ public final void execSubJob(T t) throws Exception { | |
|
||
protected abstract String getResourceType(); | ||
|
||
public interface IJobExec<T> { | ||
|
||
} | ||
|
||
public interface OwnerJobExec<T, RESULT> extends IJobExec<T> { | ||
public interface OwnerJobExec<T, RESULT> { | ||
public RESULT accept(T t) throws Exception; | ||
} | ||
|
||
public interface SubJobExec<T> extends IJobExec<T> { | ||
public interface SubJobExec<T> { | ||
public void accept(T t) throws Exception; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,21 +18,23 @@ | |
|
||
package com.qlangtech.tis.datax.job; | ||
|
||
import com.qlangtech.tis.datax.job.JobResName.OwnerJobExec; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author: 百岁([email protected]) | ||
* @create: 2024-03-11 13:18 | ||
**/ | ||
public abstract class OwnerJobResName<T, RESULT> extends JobResName<T, OwnerJobExec<T, RESULT>> { | ||
public abstract class OwnerJobResName<T, RESULT> extends JobResName<T> { | ||
|
||
private final OwnerJobExec<T, RESULT> jobExec; | ||
|
||
public OwnerJobResName(String name, OwnerJobExec<T, RESULT> jobExec) { | ||
super(name, jobExec); | ||
super(name); | ||
this.jobExec = jobExec; | ||
} | ||
|
||
@Override | ||
protected final void execute(SSERunnable sse, T t, OwnerJobExec<T, RESULT> jobExec) throws Exception { | ||
protected final void execute(SSERunnable sse, T t) throws Exception { | ||
RESULT result = jobExec.accept(t); | ||
if (result != null) { | ||
sse.setContextAttr(SSEExecuteOwner.class, new SSEExecuteOwner(result)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,20 +18,21 @@ | |
|
||
package com.qlangtech.tis.datax.job; | ||
|
||
import com.qlangtech.tis.datax.job.JobResName.SubJobExec; | ||
|
||
/** | ||
* @author: 百岁([email protected]) | ||
* @create: 2024-03-11 12:37 | ||
**/ | ||
public abstract class SubJobResName<T> extends JobResName<T, SubJobExec<T>> { | ||
public abstract class SubJobResName<T> extends JobResName<T> { | ||
|
||
private final SubJobExec<T> jobExec; | ||
|
||
SubJobResName(String name, SubJobExec<T> jobExec) { | ||
super(name, jobExec); | ||
protected SubJobResName(String name, SubJobExec<T> jobExec) { | ||
super(name); | ||
this.jobExec = jobExec; | ||
} | ||
|
||
@Override | ||
protected void execute(SSERunnable sse, T t, SubJobExec<T> jobExec) throws Exception { | ||
protected void execute(SSERunnable sse, T t) throws Exception { | ||
jobExec.accept(t); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* <p> | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.qlangtech.tis.log; | ||
|
@@ -22,47 +22,58 @@ | |
import ch.qos.logback.classic.PatternLayout; | ||
import ch.qos.logback.core.UnsynchronizedAppenderBase; | ||
import com.qlangtech.tis.datax.job.SSERunnable; | ||
import org.apache.commons.io.IOUtils; | ||
import org.apache.commons.io.LineIterator; | ||
|
||
import java.io.StringReader; | ||
|
||
/** | ||
* @author: 百岁([email protected]) | ||
* @create: 2024-02-09 10:00 | ||
**/ | ||
public class WaittingProcessCollectorAppender extends UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.LoggingEvent> { | ||
private PatternLayout layout; | ||
private PatternLayout layout; | ||
|
||
@Override | ||
public void start() { | ||
this.layout = new PatternLayout(); | ||
this.layout.setPattern("%msg%n"); | ||
this.layout.setContext(this.getContext()); | ||
super.start(); | ||
this.layout.start(); | ||
} | ||
|
||
@Override | ||
public void start() { | ||
this.layout = new PatternLayout(); | ||
this.layout.setPattern("%msg%n"); | ||
this.layout.setContext(this.getContext()); | ||
super.start(); | ||
this.layout.start(); | ||
} | ||
@Override | ||
protected void append(ch.qos.logback.classic.spi.LoggingEvent e) { | ||
// System.out.println(e.getClass()); | ||
|
||
@Override | ||
protected void append(ch.qos.logback.classic.spi.LoggingEvent e) { | ||
// System.out.println(e.getClass()); | ||
// try (BufferedReader msgReader = new BufferedReader(new StringReader(e.getFormattedMessage()))) { | ||
|
||
// try (BufferedReader msgReader = new BufferedReader(new StringReader(e.getFormattedMessage()))) { | ||
Level level = null; | ||
if (SSERunnable.sseAware()) { | ||
SSERunnable sse = SSERunnable.getLocal(); | ||
level = e.getLevel(); | ||
if (level.isGreaterOrEqual(Level.ERROR)) { | ||
|
||
Level level = null; | ||
if (SSERunnable.sseAware()) { | ||
SSERunnable sse = SSERunnable.getLocal(); | ||
level = e.getLevel(); | ||
if (level.isGreaterOrEqual(Level.ERROR)) { | ||
sse.error(null, e.getTimeStamp(), this.layout.doLayout(e)); | ||
return; | ||
} | ||
try (LineIterator lines = IOUtils.lineIterator(new StringReader(this.layout.doLayout(e)))) { | ||
while (lines.hasNext()) { | ||
sse.error(null, e.getTimeStamp(), lines.next()); | ||
} | ||
} catch (Exception ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
return; | ||
} | ||
|
||
if (level.isGreaterOrEqual(Level.DEBUG)) { | ||
sse.info(null, e.getTimeStamp(), e.getFormattedMessage()); | ||
return; | ||
} | ||
if (level.isGreaterOrEqual(Level.DEBUG)) { | ||
sse.info(null, e.getTimeStamp(), e.getFormattedMessage()); | ||
return; | ||
} | ||
|
||
|
||
throw new IllegalStateException("unhandler error level:" + level + " msg:" + e.getFormattedMessage()); | ||
throw new IllegalStateException("unhandler error level:" + level + " msg:" + e.getFormattedMessage()); | ||
} | ||
} | ||
} | ||
|
||
|
||
} |