Dataset Viewer
Auto-converted to Parquet Duplicate
proj_name
stringclasses
68 values
relative_path
stringlengths
41
329
class_name
stringlengths
1
71
func_name
stringlengths
1
89
func_body
stringlengths
0
7.52k
masked_class
stringlengths
55
8.5k
len_input
int64
25
2.02k
len_output
int64
1
1.96k
total
int64
28
2.04k
deepseek_output
stringlengths
0
5.47k
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/java/org/adoptopenjdk/jitwatch/histo/AttributeNameHistoWalker.java
AttributeNameHistoWalker
visit
String attrValue = null; if (isCompileAttribute) { attrValue = mm.getCompiledAttribute(attributeName); } else { attrValue = mm.getQueuedAttribute(attributeName); } if (attrValue != null) { long val = Long.valueOf(attrValue); histo.addValue(val); }
class AttributeNameHistoWalker extends AbstractHistoVisitable { private boolean isCompileAttribute; private String attributeName; public AttributeNameHistoWalker(IReadOnlyJITDataModel model, boolean isCompileAttribute, String attributeName, long resolution) { super(model, resolution); this.isCompileAttribute...
135
113
248
if (mm.getAttributeName().equals(attributeName)) { add(mm); }
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/java/org/adoptopenjdk/jitwatch/model/Tag.java
Tag
hashCode
int result = name != null ? name.hashCode() : 0; result = 31 * result + (attributeString != null ? attributeString.hashCode() : 0); result = 31 * result + (parent != null ? parent.hashCode() : 0); result = 31 * result + (selfClosing ? 1 : 0); result = 31 * result + (textContent ...
class Tag { private String name; private String attributeString; private List<Tag> children = new ArrayList<>(); private Tag parent = null; private boolean selfClosing = false; private boolean isFragment = false; private String textContent = null; private static final String INDENT = " "; public Tag(String...
1,715
123
1,838
int result = name != null ? name.hashCode() : 0; result = 31 * result + (attributeString != null ? attributeString.hashCode() : 0); result = 31 * result + (children != null ? children.hashCode() : 0); result = 31 * result + (parent != null ? parent.hashCode() : 0); result = 31 *...
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/java/org/adoptopenjdk/jitwatch/model/assembly/AssemblyLabels.java
AssemblyLabels
instructionToLabel
final List<String> operands = instruction.getOperands(); if (instruction.getMnemonic().startsWith("j") && operands.size() == 1) { try { return AssemblyUtil.getValueFromAddress(operands.get(0)); } catch (NumberFormatException nfe) { // could be Intel format jump to Stub:: reference } ...
class AssemblyLabels { private SortedSet<Long> addresses = new TreeSet<>(); private final Map<Long, Short> labels = new HashMap<>(); private long lowest = Long.MAX_VALUE; private long highest; public void newInstruction(AssemblyInstruction instruction) { final long address = instruction.getAddress(); lowes...
613
118
731
final Long address = instruction.getAddress(); if (instruction.getOpcode() == Opcode.LABEL) { return address; } else if (instruction.getOpcode() == Opcode.JMP || instruction.getOpcode() == Opcode.JMP_IF_FALSE) { final String operand = instruction.getOperands().get(0); if (operand.startsWith(S_HE...
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/java/org/adoptopenjdk/jitwatch/model/bytecode/LineTable.java
LineTable
sourceLineInRange
boolean result = false; int[] sourceRange = getSourceRange(); int minSourceLine = sourceRange[0]; int maxSourceLine = sourceRange[1]; result = (sourceLine >= minSourceLine) && (sourceLine <= maxSourceLine); if (DEBUG_LOGGING_BYTECODE) { logger.debug("{} in range {}-{} : {}", sourceLine, minSourceL...
class LineTable { private List<LineTableEntry> lineTableEntries = new ArrayList<>(); private static final Logger logger = LoggerFactory.getLogger(LineTable.class); private MemberBytecode memberBytecode; public LineTable(MemberBytecode memberBytecode) { this.memberBytecode = memberBytecode; } public MemberB...
1,405
127
1,532
boolean result = false; for (LineTableEntry entry : lineTableEntries) { if (entry.getSourceOffset() == sourceLine) { result = true; break; } } return result;
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/java/org/adoptopenjdk/jitwatch/parser/ParserFactory.java
ParserFactory
getParser
switch (parserType) { case HOTSPOT: return new HotSpotLogParser(jitListener); case J9: return new J9LogParser(jitListener); case ZING: return new ZingLogParser(jitListener); default: throw new RuntimeException("Unknown parser " + parserType); }
class ParserFactory { private ParserFactory() { } public static ILogParser getParser(ParserType parserType, IJITListener jitListener) {<FILL_FUNCTION_BODY>} }
56
97
153
switch (parserType) { case JIT: return new JITParser(jitListener); case JIT_OLD: return new JITParserOld(jitListener); case JIT_OLD_2: return new JITParserOld2(jitListener); case JIT_OLD_3: return new JITParserOld3(jitListener); case JIT_OLD_4: return new JITParserOld4(jitListene...
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/java/org/adoptopenjdk/jitwatch/process/runtime/RuntimeJRuby.java
RuntimeJRuby
execute
List<String> commands = new ArrayList<>(); commands.add(runtimePath.toString()); if (vmOptions.size() > 0) { commands.addAll(vmOptions); } if (classpathEntries.size() > 0) { commands.add("-cp"); commands.add(makeClassPath(classpathEntries)); } commands.add(className); return runComma...
class RuntimeJRuby extends AbstractProcess implements IRuntime { private Path runtimePath; private final String RUNTIME_NAME = "jruby" + (isWindows() ? ".bat" : S_EMPTY); public RuntimeJRuby(String languageHomeDir) throws FileNotFoundException { super(); runtimePath = Paths.get(languageHomeDir, "bin", RUNTIM...
316
141
457
List<String> command = new ArrayList<>(); command.add(runtimePath.toString()); command.add("-S"); command.add("java"); command.add("-cp"); command.add(StringUtils.join(classpathEntries, File.pathSeparatorChar)); command.addAll(vmOptions); command.add(className); return execute(workingDir, command, e...
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/java/org/adoptopenjdk/jitwatch/report/comparator/ScoreComparator.java
ScoreComparator
compare
return Integer.compare(o2.getScore(), o1.getScore());
class ScoreComparator implements Comparator<Report> { @Override public int compare(Report o1, Report o2) {<FILL_FUNCTION_BODY>} }
49
22
71
return o1.getScore() - o2.getScore();
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/java/org/adoptopenjdk/jitwatch/toplist/CompiledAttributeTopListVisitable.java
CompiledAttributeTopListVisitable
visit
if (mm.getCompiledAttribute(attr) != null) { long value = Long.valueOf(mm.getCompiledAttribute(attr)); topList.add(new MemberScore(mm, value)); }
class CompiledAttributeTopListVisitable extends AbstractTopListVisitable { private final String attr; public CompiledAttributeTopListVisitable(IReadOnlyJITDataModel model, String attr, boolean sortHighToLow) { super(model, sortHighToLow); this.attr = attr; } @Override public void visit(IMetaMember mm) {<FI...
106
62
168
double val = mm.getAttribute(attr); add(val, mm);
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/java/org/adoptopenjdk/jitwatch/toplist/NativeMethodSizeTopListVisitable.java
NativeMethodSizeTopListVisitable
visit
for (Compilation compilation : metaMember.getCompilations()) { long nativeSize = compilation.getNativeSize(); if (nativeSize != 0) { topList.add(new MemberScore(metaMember, nativeSize)); } }
class NativeMethodSizeTopListVisitable extends AbstractTopListVisitable { public NativeMethodSizeTopListVisitable(IReadOnlyJITDataModel model, boolean sortHighToLow) { super(model, sortHighToLow); ignoreTags.add(TAG_BC); ignoreTags.add(TAG_KLASS); ignoreTags.add(TAG_TYPE); ignoreTags.add(TAG_METHOD); i...
295
77
372
if (metaMember.getMethodSize() > 0) { super.visit(metaMember); }
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/java/org/adoptopenjdk/jitwatch/util/JVMSUtil.java
JVMSUtil
loadJVMS
try { Path path = Paths.get(new File(JVMS_HTML_FILENAME).toURI()); String html = new String(Files.readAllBytes(path), StandardCharsets.UTF_8); int htmlLength = html.length(); String descStart = "<div class="section-execution""; int startPos = html.indexOf(descStart); while (startPos != -1 &&...
class JVMSUtil { private static final Logger logger = LoggerFactory.getLogger(JVMSUtil.class); private static Map<String, String> bcDescriptionMap = new HashMap<>(); private static final String JVMS_HTML_FILENAME = "JVMS.html"; private static final String JVMS_CSS_FILENAME = "JVMS.css"; private JVMSUtil() { }...
917
290
1,207
File file = new File(JVMS_HTML_FILENAME); if (file.exists()) { try { Document doc = Jsoup.parse(file, StandardCharsets.UTF_8.name()); Elements elements = doc.select("div.section-execution"); for (Element element : elements) { String description = element.outerHtml(); storeByte...
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/java/org/adoptopenjdk/jitwatch/util/NetUtil.java
NetUtil
fetchURL
StringBuilder builder = new StringBuilder(); try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new URL(url).openStream()))) { String inputLine; while ((inputLine = bufferedReader.readLine()) != null) { builder.append(inputLine).append(S_NEWLINE); } } catch (Malfo...
class NetUtil { private NetUtil() { } private static final Logger logger = LoggerFactory.getLogger(NetUtil.class); public static String fetchURL(String url) {<FILL_FUNCTION_BODY>} public static boolean fetchBinary(String url, Path targetPath) { try (BufferedInputStream bufferedInputStream = new BufferedInp...
282
171
453
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new URL(url).openStream()))) { StringBuilder stringBuilder = new StringBuilder(); String line; while ((line = bufferedReader.readLine()) != null) { stringBuilder.append(line); } return stringBuilder.toString(); ...
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/resources/examples/EscapeTest.java
Wrapper2
run
String result; int matchYes = 0; int matchNo = 0; for (int i = 0; i < 100_000_000; i++) { int v1 = 0xABCD; int v2 = 0; if (random.nextBoolean()) { v2 = 0xABCD; } final Wrapper1 wrapper1 =...
class Wrapper2 { private int value; public Wrapper2(int value) { this.value = value; } public int getValue() { return this.value; } } private java.util.Random random = new java.util.Random(); public String run() {<FILL_FUNCTION_BODY>
88
237
325
Wrapper2 w = new Wrapper2(random.nextInt()); return String.valueOf(w.getValue());
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/resources/examples/EscapeTestMultipleFields.java
Wrapper2
main
String result = new EscapeTestMultipleFields().run(); System.out.println(result);
class Wrapper2 { private int v1; private int v2; private int v3; public Wrapper2(int value) { v1 = value; v2 = v1+1; v3 = v2+1; } public int getValue() { return v1 + v2 + v3; } } private java.util.Random random = new java.util.Random(); public String run() { ...
387
29
416
System.out.println(new InliningEquals().run());
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/resources/examples/HotThrow.java
HotThrow
getChar
try { return chars[index]; } catch(ArrayIndexOutOfBoundsException e) { return '*'; }
class HotThrow { private Random random = new Random(); public HotThrow() { StringBuilder builder = new StringBuilder(); String string = "The quick brown fox jumps over the lazy dog"; char[] chars = string.toCharArray(); for (int i = 0 ; i < 1_000_000; i++) { ...
209
44
253
if (index < 0 || index >= chars.length) { throw new IllegalArgumentException("Index out of bounds"); } return chars[index];
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/resources/examples/IntrinsicTest.java
IntrinsicTest
add
return a + b;
class IntrinsicTest { public IntrinsicTest(int iterations) { long dstSum = 0; int[] src = new int[] { 1, 2, 3, 4, 5 }; int[] dst = new int[src.length]; for (int i = 0; i < iterations; i++) { // x86 has intrinsic for System.arrayCopy System.arrayco...
250
10
260
return a + b;
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/resources/examples/SimpleInliningTest.java
SimpleInliningTest
main
new SimpleInliningTest();
class SimpleInliningTest { public SimpleInliningTest() { int sum = 0; // 1_000_000 is F4240 in hex for (int i = 0 ; i < 1_000_000; i++) { sum = this.add(sum, 99); // 63 hex } System.out.println("Sum:" + sum); } public int add(int a, int b) ...
171
12
183
new SimpleInliningTest();
AdoptOpenJDK_jitwatch
jitwatch/core/src/main/resources/examples/TrivialMethod.java
TrivialMethod
getCount
return count;
class TrivialMethod { private int count; public TrivialMethod() { StringBuilder builder = new StringBuilder(); for (int i = 0 ; i < 1_000_000; i++) { incCount(); int localCount = getCount(); builder.append(localCount).append("n"); } ...
180
8
188
return count;
AdoptOpenJDK_jitwatch
jitwatch/core/src/test/java/FooClassInDefaultPackage.java
FooClassInDefaultPackage
setPrimitiveParam
this.primitiveParam = primitiveParam;
class FooClassInDefaultPackage { private int primitiveParam; private int[] primitiveArrayParam; private IsUsedForTestingDefaultPackage classParam; private IsUsedForTestingDefaultPackage[] classArrayParam; public int[] getPrimitiveArrayParam() { return primitiveArrayParam; } public void setPrimitiveArra...
278
14
292
this.primitiveParam = primitiveParam;
AdoptOpenJDK_jitwatch
jitwatch/core/src/test/java/IsUsedForTestingDefaultPackage.java
IsUsedForTestingDefaultPackage
toString
return "Who watches the watchmen?";
class IsUsedForTestingDefaultPackage { // Class in the default package beginning with I (also representation on int parameter) // to regression check matching functionality @Override public String toString() {<FILL_FUNCTION_BODY>} }
62
15
77
return "IsUsedForTestingDefaultPackage";
AdoptOpenJDK_jitwatch
jitwatch/core/src/test/java/org/adoptopenjdk/jitwatch/test/DummyClassWithMain.java
DummyClassWithMain
main
System.out.println("Hello World!");
class DummyClassWithMain { public static void main(String[] args) {<FILL_FUNCTION_BODY>} }
35
16
51
System.out.println("Hello World!");
AdoptOpenJDK_jitwatch
jitwatch/core/src/test/java/org/adoptopenjdk/jitwatch/test/TestLineTable.java
TestLineTable
testNashornLineTableRegression
LineTable table = new LineTable(null); LineTableEntry entry1 = new LineTableEntry(8, 21); LineTableEntry entry2 = new LineTableEntry(1, 50); LineTableEntry entry3 = new LineTableEntry(3, 57); LineTableEntry entry4 = new LineTableEntry(5, 81); LineTableEntry entry5 = new LineTableEntry(3, 118); table.ad...
class TestLineTable { @Test public void testCompositeLineTable() { LineTable table1 = new LineTable(null); LineTable table2 = new LineTable(null); LineTableEntry entry1 = new LineTableEntry(0, 0); LineTableEntry entry2 = new LineTableEntry(5, 5); LineTableEntry entry3 = new LineTableEntry(10, 10); LineT...
1,340
184
1,524
LineTable table = new LineTable(null); table.add(new LineTableEntry(0, 0)); table.add(new LineTableEntry(1, 1)); table.add(new LineTableEntry(2, 2)); table.add(new LineTableEntry(3, 3)); table.add(new LineTableEntry(4, 4)); table.add(new LineTableEntry(5, 5)); table.add(new LineTableEntry(6, 6)); ta...
AdoptOpenJDK_jitwatch
jitwatch/core/target/classes/examples/EscapeTestMultipleFields.java
Wrapper2
run
String result; int matchYes = 0; int matchNo = 0; for (int i = 0; i < 100_000_000; i++) { int v1 = 0xABCD; int v2 = 0; // prevent the clever VM jumping straight to the answer if (random.nextBoolean()) { ...
class Wrapper2 { private int v1; private int v2; private int v3; public Wrapper2(int value) { v1 = value; v2 = v1+1; v3 = v2+1; } public int getValue() { return v1 + v2 + v3; } } private java.util.Random random = new java.util.Random(); public String run() {<FIL...
123
248
371
int n = random.nextInt(1000000); Wrapper2 w = new Wrapper2(n); return "" + w.getValue();
AdoptOpenJDK_jitwatch
jitwatch/core/target/classes/examples/EscapeTestString.java
Wrapper2
run
String result; int matchYes = 0; int matchNo = 0; for (int i = 0; i < 100_000_000; i++) { String v1 = "0xABCD"; String v2 = "0"; if (random.nextBoolean()) { v2 = "0xABCD"; } final Wrapper...
class Wrapper2 { private String value; public Wrapper2(String value) { this.value = value; } public String getValue() { return this.value; } } private java.util.Random random = new java.util.Random(); public String run() {<FILL_FUNCTION_BODY>
88
240
328
Wrapper2 w = new Wrapper2("Hello"); return w.getValue();
AdoptOpenJDK_jitwatch
jitwatch/core/target/classes/examples/HotThrow.java
HotThrow
main
new HotThrow();
class HotThrow { private Random random = new Random(); public HotThrow() { StringBuilder builder = new StringBuilder(); String string = "The quick brown fox jumps over the lazy dog"; char[] chars = string.toCharArray(); for (int i = 0 ; i < 1_000_000; i++) { ...
244
9
253
new HotThrow();
AdoptOpenJDK_jitwatch
jitwatch/core/target/classes/examples/InlineElimAlloc.java
InlineElimAlloc
main
InlineElimAlloc test = new InlineElimAlloc(); long sum = 0; for (int i = 0; i < 20_000; i++) { sum += test.outer(i); } System.out.println(sum);
class InlineElimAlloc { public long outer(int i) { long sum = 0; for (int j = 0; j < 20_000; j++) { sum += inner(i, j); } return sum; } public long inner(int i, int j) { long sum = 0; int[] parts = new int[2]; parts[0...
226
76
302
InlineElimAlloc inlineElimAlloc = new InlineElimAlloc(); for (int i = 0; i < 100; i++) { inlineElimAlloc.outer(i); }
AdoptOpenJDK_jitwatch
jitwatch/core/target/classes/examples/Lambda.java
Lambda
main
List<String> items = new ArrayList<>(); items.add("apple"); items.add("banana"); items.add("blueberry"); items.add("cherry"); items.add("pineapple"); items.add("pear"); items.add("strawberry"); List<Object> filtered = items.stream().filter( item...
class Lambda { public static void main(String[] args) {<FILL_FUNCTION_BODY>} }
34
141
175
AdoptOpenJDK_jitwatch
jitwatch/core/target/classes/examples/PartialEscapeFail.java
EscapeConsumer
run
long result = 0; EscapeConsumer consumer = new EscapeConsumer(); java.util.Random random = new java.util.Random(); for (int i = 0; i < 100_000_000; i++) { Integer integer = Integer.valueOf(i); if (random.nextBoolean()) { re...
class EscapeConsumer { public int smallEnoughToInline(Integer integer) { // 325 bytes of bytecode (inlining limit is 325) int i = integer.intValue(); return ((i + 1) >> 2) + ((i + 2) >> 2) + ((i + 3) >> 2) + ((i + 4) >> 2) + ((i + 5) >> 2) + ((i + 6) >> 2) + ((i + 7) >> 2) + ((i + 8) >> ...
1,175
168
1,343
EscapeConsumer consumer = new EscapeConsumer(); consumer.smallEnoughToInline(1); consumer.tooBigToInline(1); return "OK";
AdoptOpenJDK_jitwatch
jitwatch/core/target/classes/examples/SimpleInliningTest.java
SimpleInliningTest
main
new SimpleInliningTest();
class SimpleInliningTest { public SimpleInliningTest() { int sum = 0; // 1_000_000 is F4240 in hex for (int i = 0 ; i < 1_000_000; i++) { sum = this.add(sum, 99); // 63 hex } System.out.println("Sum:" + sum); } public int add(int a, int b) ...
171
12
183
new SimpleInliningTest();
AdoptOpenJDK_jitwatch
jitwatch/core/target/classes/examples/Sort.java
Sort
countGreaterThanHalfWithSort
long count = 0; Arrays.sort(theDoubles); for (int i = 0; i < ARRAY_LENGTH; i++) { if (theDoubles[i] > 0.5) { count++; } } return count;
class Sort { public static final int ARRAY_LENGTH = 1_000_000; public double[] doubleArray1 = new double[ARRAY_LENGTH]; public double[] doubleArray2 = new double[ARRAY_LENGTH]; public Sort() { fillArrays(); long count1 = countGreaterThanHalfWithSort(doubleArray1); long count2 = countGreaterThanHalfWithoutS...
388
85
473
Arrays.sort(theDoubles); long count = 0; for (int i = 0; i < ARRAY_LENGTH; i++) { if (theDoubles[i] > 0.5) { count++; } } return count;
AdoptOpenJDK_jitwatch
jitwatch/ui/src/main/java/org/adoptopenjdk/jitwatch/ui/report/eliminatedallocation/EliminatedAllocationRowBean.java
EliminatedAllocationRowBean
getEliminatedType
String type = null; Object metaData = report.getMetaData(); if (metaData instanceof MetaClass) { type = ((MetaClass)metaData).getFullyQualifiedName(); } else if (metaData instanceof String) { type = (String)metaData; } else { type = "Unknown"; } return type;
class EliminatedAllocationRowBean extends AbstractReportRowBean { public EliminatedAllocationRowBean(Report report) { super(report); } public String getCompilation() { Compilation compilation = report.getCaller().getCompilation(report.getCompilationIndex()); return compilation != null ? compilation.getSign...
239
116
355
return report.getCaller().getEliminatedType().getFullyQualifiedName();
AdoptOpenJDK_jitwatch
jitwatch/ui/src/main/java/org/adoptopenjdk/jitwatch/ui/report/inlining/InliningRowBuilder.java
InliningRowBuilder
call
return new TextTableCell();
class InliningRowBuilder { private InliningRowBuilder() { } public static TableView<IReportRowBean> buildTable(ObservableList<IReportRowBean> rows) { TableView<IReportRowBean> tv = new TableView<>(); TableColumn<IReportRowBean, String> metaClass = new TableColumn<>("Caller Class"); metaClass.setCellValueFa...
1,104
11
1,115
return new TextTableCell();
AdoptOpenJDK_jitwatch
jitwatch/ui/src/main/java/org/adoptopenjdk/jitwatch/ui/triview/bytecode/BytecodeLabel.java
BytecodeLabel
getInstruction
return instruction;
class BytecodeLabel extends InstructionLabel { private BytecodeInstruction instruction; public BytecodeLabel(BytecodeInstruction instr, int maxOffset, int line) { super(instr.toString(maxOffset, line)); instruction = instr; } public BytecodeInstruction getInstruction() {<FILL_FUNCTION_BODY>} }
95
8
103
return instruction;
alibaba_canal
canal/admin/admin-web/src/main/java/com/alibaba/otter/canal/admin/handler/CustomExceptionHandler.java
CustomExceptionHandler
commonExceptionHandle
if (e instanceof ServiceException) { logger.error(e.getMessage()); } else { logger.error(e.getMessage(), e); } BaseModel res = new BaseModel(); res.setCode(50000); res.setMessage(e.getMessage()); return res;
class CustomExceptionHandler { private static Logger logger = LoggerFactory.getLogger(CustomExceptionHandler.class); /** * * * @param e * @return */ @ResponseBody @ResponseStatus(HttpStatus.OK) @ExceptionHandler(value = Exception.class) public BaseModel commonExcepti...
114
82
196
logger.error("Exception:", e); return new BaseModel(e.getMessage());
alibaba_canal
canal/admin/admin-web/src/main/java/com/alibaba/otter/canal/admin/model/Model.java
Model
saveOrUpdate
try { EbeanServer ebeanServer = Ebean.getDefaultServer(); Object id = ebeanServer.getBeanId(this); if (id == null) { init(); this.save(); } else { this.update(); } } catch (Exception e) { ...
class Model extends io.ebean.Model { public void init() { } public void save() { init(); super.save(); } public void insert() { init(); super.insert(); } public void saveOrUpdate() {<FILL_FUNCTION_BODY>} public void update(String... propertiesNames) {...
360
94
454
init(); super.saveOrUpdate();
alibaba_canal
canal/admin/admin-web/src/main/java/com/alibaba/otter/canal/admin/model/NodeServer.java
NodeServerFinder
init
status = "-1";
class NodeServerFinder extends Finder<Long, NodeServer> { /** * Construct using the default EbeanServer. */ public NodeServerFinder(){ super(NodeServer.class); } } @Id private Long id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(nam...
216
10
226
if (adminPort == null) { adminPort = CanalCluster.DEFAULT_ADMIN_PORT; } if (metricPort == null) { metricPort = CanalCluster.DEFAULT_METRIC_PORT; } if (tcpPort == null) { tcpPort = CanalCluster.DEFAULT_TCP_PORT; } } public Long...
alibaba_canal
canal/client-adapter/clickhouse/src/test/java/com/alibaba/otter/canal/client/adapter/clickhouse/sync/Common.java
Common
init
DatasourceConfig.DATA_SOURCES.put("defaultDS", TestConstant.dataSource); OuterAdapterConfig outerAdapterConfig = new OuterAdapterConfig(); outerAdapterConfig.setName("clickhouse"); outerAdapterConfig.setKey("clickhouse1"); Map<String, String> properties = new HashMap<>(); ...
class Common { public static ClickHouseAdapter init() {<FILL_FUNCTION_BODY>} /** * set global log level * * @param logLevel */ public static void setLogLevel(Level logLevel) { ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory .getL...
129
220
349
ClickHouseAdapter adapter = new ClickHouseAdapter(); adapter.setUrl("jdbc:clickhouse://localhost:8123/default"); adapter.setUsername("default"); adapter.setPassword(""); adapter.setDatabase("default"); adapter.setTable("test"); adapter.setBatchSize(1000); ...
alibaba_canal
canal/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/ProxyOuterAdapter.java
ProxyOuterAdapter
count
ClassLoader cl = changeCL(); try { return OuterAdapter.super.count(task); } finally { revertCL(cl); }
class ProxyOuterAdapter implements OuterAdapter { private OuterAdapter outerAdapter; public ProxyOuterAdapter(OuterAdapter outerAdapter) { this.outerAdapter = outerAdapter; } private ClassLoader changeCL() { ClassLoader cl = Thread.currentThread().getContextClassLoader(); Thre...
490
45
535
ClassLoader cl = changeCL(); try { return OuterAdapter.super.count(task); } finally { revertCL(cl); }
alibaba_canal
canal/client-adapter/es7x/src/test/java/com/alibaba/otter/canal/client/adapter/es7x/test/ESConnectionTest.java
ESConnectionTest
test01
MappingMetaData mappingMetaData = esConnection.getMapping("mytest_user"); Map<String, Object> sourceMap = mappingMetaData.getSourceAsMap(); Map<String, Object> esMapping = (Map<String, Object>) sourceMap.get("properties"); for (Map.Entry<String, Object> entry : esMapping.entrySet()) { ...
class ESConnectionTest { ESConnection esConnection; @Before public void init() throws UnknownHostException { String[] hosts = new String[] { "127.0.0.1:9200" }; Map<String, String> properties = new HashMap<>(); properties.put("cluster.name", "elasticsearch"); esConnection =...
141
212
353
esConnection.getClient();
alibaba_canal
canal/client-adapter/es8x/src/main/java/com/alibaba/otter/canal/client/adapter/es8x/etl/ESEtlService.java
ESEtlService
executeSqlImport
try { ESMapping mapping = (ESMapping) adapterMapping; Util.sqlRS(ds, sql, values, rs -> { int count = 0; try { ESBulkRequest esBulkRequest = this.esConnection.new ES8xBulkRequest(); long batchBegin = System.current...
class ESEtlService extends AbstractEtlService { private ESConnection esConnection; private ESTemplate esTemplate; private ESSyncConfig config; public ESEtlService(ESConnection esConnection, ESSyncConfig config){ super("ES", config); this.esConnection = esConnection; this.esTe...
243
1,481
1,724
try { int batchSize = config.getBatchSize(); int batchCount = 0; List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> result = new ArrayList<>(); List<Map<String, Object>> result1 = new ArrayList<>(); List<Map<Stri...
alibaba_canal
canal/client-adapter/kudu/src/main/java/com/alibaba/otter/canal/client/adapter/kudu/support/SyncUtil.java
SyncUtil
getColumnsMap
Map<String, String> columnsMap; if (kuduMapping.getMapAll()) { if (kuduMapping.getAllMapColumns() != null) { return kuduMapping.getAllMapColumns(); } columnsMap = new LinkedHashMap<>(); for (String srcColumn : columns) { bo...
class SyncUtil { /** * * * @param kuduMapping * @return */ public static String getDbTableName(KuduMappingConfig.KuduMapping kuduMapping) { String result = ""; if (StringUtils.isNotEmpty(kuduMapping.getTable())) { result += kuduMapping.getDatabase() + ".";...
224
254
478
Map<String, String> columnsMap = new HashMap<>(); for (String column : columns) { String columnName = kuduMapping.getColumnMap().get(column); if (StringUtils.isEmpty(columnName)) { columnName = column; } columnsMap.put(column, columnName);...
alibaba_canal
canal/client-adapter/launcher/src/main/java/com/alibaba/otter/canal/adapter/launcher/common/SyncSwitch.java
SyncSwitch
on
if (mode == Mode.LOCAL) { BooleanMutex mutex = LOCAL_LOCK.get(destination); if (mutex != null && !mutex.state()) { mutex.set(true); } } else { try { String path = SYN_SWITCH_ZK_NODE + destination; try { ...
class SyncSwitch { private static final String SYN_SWITCH_ZK_NODE = "/sync-switch/"; private static final Map<String, BooleanMutex> LOCAL_LOCK = new ConcurrentHashMap<>(); private static final Map<String, BooleanMutex> DISTRIBUTED_LOCK = new ConcurrentHashMap<>(); privat...
1,779
226
2,005
if (mode == Mode.LOCAL) { BooleanMutex mutex = LOCAL_LOCK.get(destination); if (mutex != null && !mutex.state()) { mutex.set(true); } } else { try { String path = SYN_SWITCH_ZK_NODE + destination; try { ...
alibaba_canal
canal/client-adapter/phoenix/src/main/java/com/alibaba/otter/canal/client/adapter/phoenix/support/BatchExecutor.java
BatchExecutor
rollback
getConn().rollback(); if (logger.isTraceEnabled()) { logger.trace("Batch executor rollback " + idx.get() + " rows"); } idx.set(0);
class BatchExecutor implements Closeable { private static final Logger logger = LoggerFactory.getLogger(BatchExecutor.class); private DataSource dataSource; private Connection conn; private AtomicInteger idx = new AtomicInteger(0); public BatchExecutor(DataSource dataSo...
682
55
737
getConn().rollback(); if (logger.isTraceEnabled()) { logger.trace("Batch executor rollback " + idx.get() + " rows"); } idx.set(0);
alibaba_canal
canal/client-adapter/phoenix/src/test/java/com/alibaba/otter/canal/client/adapter/phoenix/test/TestConfigLoad.java
TestConfigLoad
testLoad
Map<String, MappingConfig> configMap = ConfigLoader.load(null); Assert.assertFalse(configMap.isEmpty());
class TestConfigLoad { @Before public void before() { // DatasourceConfig.DATA_SOURCES.put("defaultDS", TestConstant.dataSource); } @Test public void testLoad() {<FILL_FUNCTION_BODY>} }
81
35
116
// Assert.assertNotNull(DatasourceConfig.getDataSource("defaultDS"));
alibaba_canal
canal/client-adapter/tablestore/src/main/java/com/alibaba/otter/canal/client/adapter/tablestore/config/ConfigLoader.java
ConfigLoader
load
logger.info("## Start loading tablestore mapping config ... "); Map<String, MappingConfig> result = new LinkedHashMap<>(); Map<String, String> configContentMap = MappingConfigsLoader.loadConfigs("tablestore"); configContentMap.forEach((fileName, content) -> { MappingConfig...
class ConfigLoader { private static Logger logger = LoggerFactory.getLogger(ConfigLoader.class); /** * RDB * * @return /-- */ public static Map<String, MappingConfig> load(Properties envProperties) {<FILL_FUNCTION_BODY>} }
95
229
324
Map<String, MappingConfig> mappingConfigMap = new HashMap<>(); try { String configPath = envProperties.getProperty("config.path"); if (StringUtils.isBlank(configPath)) { configPath = "config/mapping.properties"; } InputStream inputStream =...
alibaba_canal
canal/client-adapter/tablestore/src/main/java/com/alibaba/otter/canal/client/adapter/tablestore/service/TablestoreEtlService.java
TablestoreEtlService
executeSqlImport
try { MappingConfig.DbMapping dbMapping = (MappingConfig.DbMapping) mapping; Map<String, String> columnsMap = dbMapping.getTargetColumnsParsed(); Util.sqlRS(srcDS, sql, values, rs -> { int idx = 0; List<Future<WriterResult>> futureList = new...
class TablestoreEtlService extends AbstractEtlService { private TableStoreWriter writer; private MappingConfig config; private TablestoreSyncService syncService; public TablestoreEtlService(TableStoreWriter writer, MappingConfig config){ super("Tablestore", config); this.writer = writ...
429
585
1,014
try { Connection conn = srcDS.getConnection(); PreparedStatement pstmt = conn.prepareStatement(sql); for (int i = 0; i < values.size(); i++) { pstmt.setObject(i + 1, values.get(i)); } ResultSet rs = pstmt.executeQuery(); Ma...
alibaba_canal
canal/client/src/main/java/com/alibaba/otter/canal/client/impl/SimpleNodeAccessStrategy.java
SimpleNodeAccessStrategy
nextNode
try { return nodes.get(index); } finally { index = (index + 1) % nodes.size(); }
class SimpleNodeAccessStrategy implements CanalNodeAccessStrategy { private List<SocketAddress> nodes = new ArrayList<>(); private int index = 0; public SimpleNodeAccessStrategy(List<? extends SocketAddress> nodes){ if (nodes == null || nodes.size() < 1) { throw new Ill...
159
38
197
if (index >= nodes.size()) { index = 0; } return nodes.get(index++);
alibaba_canal
canal/client/src/main/java/com/alibaba/otter/canal/client/kafka/protocol/KafkaMessage.java
KafkaMessage
getOffset
return offset;
class KafkaMessage extends Message { private static final long serialVersionUID = -293120358490119447L; /** * Kafka offset */ private long offset; public KafkaMessage(Message message, long offset){ super(message.getId()); BeanUtils.copyProperties(mes...
177
10
187
return offset;
alibaba_canal
canal/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/CreateFileLogEvent.java
CreateFileLogEvent
getBuffer
return blockBuf;
class CreateFileLogEvent extends LoadLogEvent { protected LogBuffer blockBuf; protected int blockLen; protected long fileId; protected boolean initedFromOld; /* CF = "Create File" */ public static final int CF_FILE_ID_OFFSET = 0; public static final ...
615
11
626
return blockBuf;
alibaba_canal
canal/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/IncidentLogEvent.java
IncidentLogEvent
getIncident
return incident;
class IncidentLogEvent extends LogEvent { public static final int INCIDENT_NONE = 0; /** There are possibly lost events in the replication stream */ public static final int INCIDENT_LOST_EVENTS = 1; /** Shall be last event of the enumeration */ public static final int INCIDENT_COUN...
413
10
423
return incident;
alibaba_canal
canal/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/IntvarLogEvent.java
IntvarLogEvent
getQuery
return "SET INSERT_ID = " + value;
class IntvarLogEvent extends LogEvent { /** * Fixed data part: Empty * <p> * Variable data part: * <ul> * <li>1 byte. A value indicating the variable type: LAST_INSERT_ID_EVENT = * 1 or INSERT_ID_EVENT = 2.</li> * <li>8 bytes. An unsigned integer indicating the value to be used f...
477
16
493
return "SET @@" + (type == LAST_INSERT_ID_EVENT ? "LAST_INSERT_ID" : "INSERT_ID") + " = " + value;
alibaba_canal
canal/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/RowsQueryLogEvent.java
RowsQueryLogEvent
getRowsQuery
return rowsQuery;
class RowsQueryLogEvent extends IgnorableLogEvent { private String rowsQuery; public RowsQueryLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){ super(header, buffer, descriptionEvent); final int commonHeaderLen = descriptionEvent.commonHeaderLen; ...
216
9
225
return rowsQuery;
alibaba_canal
canal/dbsync/src/test/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcherTest.java
DirectLogFetcherTest
processEvent
int eventType = event.getHeader().getType(); switch (eventType) { case LogEvent.ROTATE_EVENT: binlogFileName = ((RotateLogEvent) event).getFilename(); break; case LogEvent.BINLOG_CHECKPOINT_EVENT: binlogFileName = ((BinlogCheckPoin...
class DirectLogFetcherTest extends BaseLogFetcherTest { @Test public void testSimple() { DirectLogFetcher fecther = new DirectLogFetcher(); try { Class.forName("com.mysql.jdbc.Driver"); Connection connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306", "r...
418
466
884
if (event.getType() == LogEvent.ROTATE_EVENT) { LogRotateEvent rotateEvent = (LogRotateEvent) event; System.out.println("rotateEvent: " + rotateEvent.getBinlogName() + " " + rotateEvent.getBinlogPos()); } else if (event.getType() == LogEvent.FORMAT_DESCRIPTION_EVENT) { ...
alibaba_canal
canal/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/client/ClientAuthenticationPacket.java
ClientAuthenticationPacket
toBytes
ByteArrayOutputStream out = new ByteArrayOutputStream(); // 1. write client_flags ByteHelper.writeUnsignedIntLittleEndian(clientCapability, out); // remove // client_interactive // feature // 2. write max_packet_size ByteHelper.writeUnsignedIntLittleEndian(MSC.M...
class ClientAuthenticationPacket extends PacketWithHeaderPacket { private int clientCapability = Capability.CLIENT_LONG_PASSWORD | Capability.CLIENT_LONG_FLAG | Capability.CLIENT_PROTOCOL_41 | Capability.CLIENT_INTERACTIVE | Capability....
831
454
1,285
ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); dos.writeInt(clientCapability); dos.writeInt(getMaxPacketSize()); dos.writeByte(charsetNumber); dos.write(new byte[23]); dos.write(username.getBytes(Char...
alibaba_canal
canal/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/client/QueryCommandPacket.java
QueryCommandPacket
toBytes
ByteArrayOutputStream out = new ByteArrayOutputStream(); out.write(getCommand()); out.write(getQueryString().getBytes("UTF-8"));// UTF-8 return out.toByteArray();
class QueryCommandPacket extends CommandPacket { private String queryString; public QueryCommandPacket(){ setCommand((byte) 0x03); } public void fromBytes(byte[] data) throws IOException { } public byte[] toBytes() throws IOException {<FILL_FUNCTION_BODY>} public void setQuerySt...
135
66
201
return null;
alibaba_canal
canal/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/server/RowDataPacket.java
RowDataPacket
fromBytes
int index = 0; LengthCodedStringReader reader = new LengthCodedStringReader(null, index); do { getColumns().add(reader.readLengthCodedString(data)); } while (reader.getIndex() < data.length);
class RowDataPacket extends PacketWithHeaderPacket { private List<String> columns = new ArrayList<>(); public void fromBytes(byte[] data) throws IOException {<FILL_FUNCTION_BODY>} public byte[] toBytes() throws IOException { return null; } public void setColumns(List<String> columns) { ...
154
68
222
ByteArrayInputStream bais = new ByteArrayInputStream(data); DataInputStream dis = new DataInputStream(bais); int columnCount = dis.readUnsignedByte(); for (int i = 0; i < columnCount; i++) { columns.add(dis.readUTF()); }
alibaba_canal
canal/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/SocketChannelPool.java
SocketChannelPool
chooseSocketChannel
String socketChannel = System.getenv("canal.socketChannel"); if (StringUtils.isEmpty(socketChannel)) { socketChannel = System.getProperty("canal.socketChannel"); } if (StringUtils.isEmpty(socketChannel)) { socketChannel = "bio"; // bio or netty } ...
class SocketChannelPool { public static SocketChannel open(SocketAddress address) throws Exception { String type = chooseSocketChannel(); if ("netty".equalsIgnoreCase(type)) { return NettySocketChannelPool.open(address); } else { return BioSocketChannelPool.open(addr...
109
90
199
return System.getProperty("socket.channel", "netty");
alibaba_canal
canal/driver/src/test/java/com/alibaba/otter/canal/parse/driver/mysql/packets/client/RegisterSlaveCommandPacketTest.java
RegisterSlaveCommandPacketTest
toBytesOutput27
// Arrange final RegisterSlaveCommandPacket objectUnderTest = new RegisterSlaveCommandPacket(); objectUnderTest.serverId = 0L; objectUnderTest.reportPort = 0; objectUnderTest.reportPasswd = "foo"; objectUnderTest.reportHost = "foo"; objectUnderTest.reportUser = ...
class RegisterSlaveCommandPacketTest { @Rule public final ExpectedException thrown = ExpectedException.none(); @SuppressWarnings("deprecation") @Rule public final Timeout globalTimeout = new Timeout(10000); /* testedClasses: RegisterSlaveCommandPacket */ // Test written b...
243
329
572
// Arrange final int n = 27; // Act final byte[] actual = RegisterSlaveCommandPacket.toBytes(n); // Assert result Assert.assertArrayEquals(new byte[] { (byte) 0, (byte) 0, (byte) 0, (byte) 27 }, actual);
alibaba_canal
canal/example/src/main/java/com/alibaba/otter/canal/example/rocketmq/CanalRocketMQClientFlatMessageExample.java
CanalRocketMQClientFlatMessageExample
process
while (!running) { try { Thread.sleep(1000); } catch (InterruptedException e) { } } while (running) { try { connector.connect(); connector.subscribe(); while (running) { ...
class CanalRocketMQClientFlatMessageExample extends AbstractRocektMQTest { protected final static Logger logger = LoggerFactory .getLogger(CanalRocketMQClientFlatMessageExample.class); private RocketMQCanalConnector connector; private static volatile boolean running = ...
622
261
883
try { connector.connect(); connector.subscribe(); while (running) { try { final Message message = connector.getWithoutAck(1000); if (message != null) { final List<Entry> entries = message.getEntr...
alibaba_canal
canal/instance/spring/src/main/java/com/alibaba/otter/canal/instance/spring/CanalInstanceWithSpring.java
CanalInstanceWithSpring
setEventStore
this.eventStore = eventStore;
class CanalInstanceWithSpring extends AbstractCanalInstance { private static final Logger logger = LoggerFactory.getLogger(CanalInstanceWithSpring.class); public void start() { logger.info("start CannalInstance for {}-{} ", new Object[] { 1, destination }); super.start(); } // =======...
323
13
336
this.eventStore = eventStore;
alibaba_canal
canal/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/ddl/DdlResult.java
DdlResult
setSchemaName
this.schemaName = schemaName;
class DdlResult { private String schemaName; private String tableName; private String oriSchemaName; // rename ddl private String oriTableName; // rename ddl private EventType type; private DdlResult renameTableResult; // rename table /* * RENAME TABLE tbl_name TO n...
854
13
867
this.schemaName = schemaName;
alibaba_canal
canal/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/RdsLocalBinlogEventParser.java
RdsLocalBinlogEventParser
onFinish
try { binlogDownloadQueue.downOne(); File needDeleteFile = new File(directory + File.separator + fileName); if (needDeleteFile.exists()) { needDeleteFile.delete(); } // logManager LogPosition logPosition = logPositionManage...
class RdsLocalBinlogEventParser extends LocalBinlogEventParser implements CanalEventParser, LocalBinLogConnection.FileParserListener { private String url; // openapi private String accesskey; // ak private String secretkey; // sk p...
1,254
500
1,754
if (finishListener != null) { finishListener.onFinish(); }
alibaba_canal
canal/parse/src/test/java/com/alibaba/otter/canal/parse/helper/TimeoutChecker.java
TimeoutChecker
touch
this.lastTouch = System.currentTimeMillis();
class TimeoutChecker { /** * */ private long lastTouch; /** * */ private long timeoutMillis; /** * */ private boolean running = true; /** * default 3s */ private static fin...
356
19
375
this.lastTouch = System.currentTimeMillis();
alibaba_canal
canal/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/MetaSnapshotDAOTest.java
MetaSnapshotDAOTest
testSimple
MetaSnapshotDO metaSnapshotDO = new MetaSnapshotDO(); metaSnapshotDO.setDestination("test"); metaSnapshotDO.setBinlogFile("000001"); metaSnapshotDO.setBinlogOffest(4L); metaSnapshotDO.setBinlogMasterId("1"); metaSnapshotDO.setBinlogTimestamp(System.currentTimeMillis() - ...
class MetaSnapshotDAOTest { @Resource MetaSnapshotDAO metaSnapshotDAO; @Ignore @Test public void testSimple() {<FILL_FUNCTION_BODY>} }
58
210
268
MetaSnapshot metaSnapshot = new MetaSnapshot(); metaSnapshot.setId(1); metaSnapshot.setName("test"); metaSnapshot.setType(1); metaSnapshot.setContent("test"); metaSnapshot.setCreateTime(new Date()); metaSnapshot.setUpdateTime(new Date()); metaSnapshot.set...
alibaba_canal
canal/parse/src/test/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/TableMetaManagerTest.java
TableMetaManagerTest
testSimple
tableMetaManager.init("test"); URL url = Thread.currentThread().getContextClassLoader().getResource("dummy.txt"); File dummyFile = new File(url.getFile()); File create = new File(dummyFile.getParent() + "/ddl", "create.sql"); EntryPosition position = new EntryPosition("mysql-bi...
class TableMetaManagerTest { @Resource DatabaseTableMeta tableMetaManager; @Test public void testSimple() throws FileNotFoundException, IOException {<FILL_FUNCTION_BODY>} }
54
301
355
String sql = "CREATE TABLE `t_user` (\n" + " `id` bigint(20) NOT NULL AUTO_INCREMENT,\n" + " `name` varchar(255) DEFAULT NULL,\n" + " `age` int(11) DEFAULT NULL,\n" + " `create_time` datetime DEFAULT NULL,\n" + " `update_time`...
alibaba_canal
canal/parse/src/test/java/com/alibaba/otter/canal/parse/index/MemoryLogPositionManagerTest.java
MemoryLogPositionManagerTest
testAll
MemoryLogPositionManager logPositionManager = new MemoryLogPositionManager(); logPositionManager.start(); doTest(logPositionManager); logPositionManager.stop();
class MemoryLogPositionManagerTest extends AbstractLogPositionManagerTest { @Test public void testAll() {<FILL_FUNCTION_BODY>} }
41
44
85
MemoryLogPositionManager manager = new MemoryLogPositionManager(); testAll(manager);
alibaba_canal
canal/parse/src/test/java/com/alibaba/otter/canal/parse/index/PeriodMixedLogPositionManagerTest.java
PeriodMixedLogPositionManagerTest
testAll
MemoryLogPositionManager memoryLogPositionManager = new MemoryLogPositionManager(); ZooKeeperLogPositionManager zookeeperLogPositionManager = new ZooKeeperLogPositionManager(zkclientx); PeriodMixedLogPositionManager logPositionManager = new PeriodMixedLogPositionManager(memoryLogPositionManage...
class PeriodMixedLogPositionManagerTest extends AbstractLogPositionManagerTest { private ZkClientx zkclientx = new ZkClientx(cluster1 + ";" + cluster2); @Before public void setUp() { String path = ZookeeperPathUtils.getDestinationPath(destination); zkclientx.deleteRecursive(path); } ...
171
238
409
PeriodMixedLogPositionManager logPositionManager = new PeriodMixedLogPositionManager(zkclientx, destination, period, period, period); testAll(logPositionManager);
alibaba_canal
canal/parse/src/test/java/com/alibaba/otter/canal/parse/index/ZooKeeperLogPositionManagerTest.java
ZooKeeperLogPositionManagerTest
setUp
String path = ZookeeperPathUtils.getDestinationPath(destination); zkclientx.deleteRecursive(path);
class ZooKeeperLogPositionManagerTest extends AbstractLogPositionManagerTest { private ZkClientx zkclientx = new ZkClientx(cluster1 + ";" + cluster2); @Before public void setUp() {<FILL_FUNCTION_BODY>} @After public void tearDown() { String path = ZookeeperPathUtils.getDestinationPath(dest...
197
37
234
String path = ZookeeperPathUtils.getDestinationPath(destination); zkclientx.createPersistent(path, true);
alibaba_canal
canal/prometheus/src/main/java/com/alibaba/otter/canal/prometheus/impl/PrometheusClientInstanceProfiler.java
SingletonHolder
stop
running = false; if (outboundCounter != null) { CollectorRegistry.defaultRegistry.unregister(outboundCounter); } if (packetsCounter != null) { CollectorRegistry.defaultRegistry.unregister(packetsCounter); } if (emptyBatchesCounter != null) { ...
class SingletonHolder { private static final PrometheusClientInstanceProfiler SINGLETON = new PrometheusClientInstanceProfiler(); } public static PrometheusClientInstanceProfiler instance() { return SingletonHolder.SINGLETON; } private PrometheusClientInstanceProfiler() { this....
822
166
988
if (outboundCounter != null) { outboundCounter.clear(); } if (packetsCounter != null) { packetsCounter.clear(); } if (emptyBatchesCounter != null) { emptyBatchesCounter.clear(); } if (errorsCounter != null) { errors...
alibaba_canal
canal/server/src/main/java/com/alibaba/otter/canal/admin/handler/SessionHandler.java
SessionHandler
exceptionCaught
logger.error("something goes wrong with channel:{}, exception={}", ctx.getChannel(), ExceptionUtils.getStackTrace(e.getCause())); ctx.getChannel().close();
class SessionHandler extends SimpleChannelHandler { private static final Logger logger = LoggerFactory.getLogger(SessionHandler.class); private CanalAdmin canalAdmin; public SessionHandler(){ } public SessionHandler(CanalAdmin canalAdmin){ this.canalAdmin = canalAdmin; } ...
1,341
53
1,394
logger.error("exception caught in session handler", e.getCause());
alibaba_canal
canal/server/src/main/java/com/alibaba/otter/canal/admin/netty/AdminNettyUtils.java
AdminNettyUtils
errorPacket
return Packet.newBuilder() .setType(AdminPacket.PacketType.ACK) .setVersion(VERSION) .setBody(Ack.newBuilder().setCode(errorCode).setMessage(errorMessage).build().toByteString()) .build() .toByteArray();
class AdminNettyUtils { public static int HEADER_LENGTH = 4; public static int VERSION = 1; public static void write(Channel channel, ByteBuffer body) { byte[] header = ByteBuffer.allocate(HEADER_LENGTH).order(ByteOrder.BIG_ENDIAN).putInt(body.limit()).array(); List<ChannelBuffer> co...
504
78
582
return Packet.newBuilder() .setType(AdminPacket.PacketType.ERROR) .setVersion(VERSION) .setBody(Error.newBuilder().setCode(errorCode).setMessage(errorMessage).build().toByteString()) .build() .toByteArray();
alibaba_canal
canal/sink/src/main/java/com/alibaba/otter/canal/sink/entry/group/GroupEventSink.java
GroupEventSink
start
super.start(); if (filterTransactionEntry) { barrier = new TimelineBarrier(groupSize); } else { barrier = new TimelineTransactionBarrier(groupSize);// }
class GroupEventSink extends EntryEventSink { private int groupSize; private GroupBarrier barrier; // sink public GroupEventSink(){ this(1); } public GroupEventSink(int groupSize){ super(); this.groupSize = groupSize; } public void start() {<FILL_FUNCTIO...
386
60
446
super.start(); barrier = new GroupBarrier(groupSize);
alibaba_canal
canal/store/src/main/java/com/alibaba/otter/canal/store/model/Event.java
Event
getRowsCount
return rowsCount;
class Event implements Serializable { private static final long serialVersionUID = 1333330351758762739L; private LogIdentity logIdentity; // private ByteString rawEntry; private long executeTime; private EntryType entryType; privat...
1,155
9
1,164
return rowsCount;
alibaba_canal
canal/store/src/test/java/com/alibaba/otter/canal/store/memory/buffer/MemoryEventStoreBase.java
MemoryEventStoreBase
buildEvent
Header.Builder headerBuilder = Header.newBuilder(); headerBuilder.setLogfileName(binlogFile); headerBuilder.setLogfileOffset(offset); headerBuilder.setExecuteTime(timestamp); headerBuilder.setEventLength(eventLenght); Entry.Builder entryBuilder = Entry.newBuilder(); ...
class MemoryEventStoreBase { private static final String MYSQL_ADDRESS = "127.0.0.1"; protected void sleep(Long time) { try { Thread.sleep(time); } catch (InterruptedException e) { Assert.fail(); } } protected Event buildEvent(String binlogFile, long of...
280
143
423
Header.Builder headerBuilder = Header.newBuilder(); headerBuilder.setLogfileName(binlogFile); headerBuilder.setLogfileOffset(offset); headerBuilder.setExecuteTime(timestamp); headerBuilder.setEventLength(eventLenght); Entry.Builder entryBuilder = Entry.newBuilder(); ...
alibaba_COLA
COLA/cola-components/cola-component-extension-starter/src/test/java/com/alibaba/cola/extension/test/Application.java
Application
main
SpringApplication.run(Application.class, args);
class Application { public static void main(String[] args) {<FILL_FUNCTION_BODY>} }
31
16
47
SpringApplication.run(Application.class, args);
alibaba_COLA
COLA/cola-components/cola-component-extension-starter/src/test/java/com/alibaba/cola/extension/test/customer/app/extension/AddCustomerBizOneValidator.java
AddCustomerBizOneValidator
validate
//For BIZ TWO CustomerTYpe could not be VIP if(CustomerType.VIP == addCustomerCmd.getCustomerDTO().getCustomerType()) throw new BizException("Customer Type could not be VIP for Biz One");
class AddCustomerBizOneValidator implements AddCustomerValidatorExtPt { public void validate(AddCustomerCmd addCustomerCmd) {<FILL_FUNCTION_BODY>} }
45
62
107
if (addCustomerCmd.getCustomerName().contains("1")) { throw new BizException("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
alibaba_COLA
COLA/cola-components/cola-component-extension-starter/src/test/java/com/alibaba/cola/extension/test/customer/app/extension/CustomerBizTwoConvertorExt.java
CustomerBizTwoConvertorExt
clientToEntity
CustomerEntity customerEntity = customerConvertor.clientToEntity(addCustomerCmd); //In this business, if customers from RFQ and Advertisement are both regarded as Advertisement if(Constants.SOURCE_AD.equals(addCustomerCmd.getCustomerDTO().getSource()) || Constants.SOURCE_RFQ.equals(addCustomerC...
class CustomerBizTwoConvertorExt implements CustomerConvertorExtPt { @Autowired private CustomerConvertor customerConvertor;//Composite basic convertor to do basic conversion @Override public CustomerEntity clientToEntity(AddCustomerCmd addCustomerCmd){<FILL_FUNCTION_BODY>} }
80
122
202
CustomerEntity customerEntity = customerConvertor.clientToEntity(addCustomerCmd); customerEntity.setCustomerType(CustomerType.BizTwo); return customerEntity;
alibaba_COLA
COLA/cola-components/cola-component-extension-starter/src/test/java/com/alibaba/cola/extension/test/customer/client/CustomerDTO.java
CustomerDTO
setSource
this.source = source;
class CustomerDTO extends DTO { private String companyName; private String source; //advertisement, p4p, RFQ, ATM private CustomerType customerType; //potential, intentional, important, vip public String getCompanyName() { return companyName; } public void setCompanyName(String compa...
195
11
206
this.source = source;
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
10