repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
belaban/JGroups | src/org/jgroups/protocols/SEQUENCER2.java | SEQUENCER2.handleTmpView | private void handleTmpView(View v) {
Address new_coord=v.getCoord();
if(new_coord != null && !new_coord.equals(coord) && local_addr != null && local_addr.equals(new_coord))
handleViewChange(v);
} | java | private void handleTmpView(View v) {
Address new_coord=v.getCoord();
if(new_coord != null && !new_coord.equals(coord) && local_addr != null && local_addr.equals(new_coord))
handleViewChange(v);
} | [
"private",
"void",
"handleTmpView",
"(",
"View",
"v",
")",
"{",
"Address",
"new_coord",
"=",
"v",
".",
"getCoord",
"(",
")",
";",
"if",
"(",
"new_coord",
"!=",
"null",
"&&",
"!",
"new_coord",
".",
"equals",
"(",
"coord",
")",
"&&",
"local_addr",
"!=",
... | an immediate change of view. See JGRP-1452. | [
"an",
"immediate",
"change",
"of",
"view",
".",
"See",
"JGRP",
"-",
"1452",
"."
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/SEQUENCER2.java#L310-L314 | train |
belaban/JGroups | src/org/jgroups/demos/QuoteServer.java | QuoteServer.integrate | private void integrate(HashMap<String,Float> state) {
if(state != null)
state.keySet().forEach(key -> stocks.put(key, state.get(key)));
} | java | private void integrate(HashMap<String,Float> state) {
if(state != null)
state.keySet().forEach(key -> stocks.put(key, state.get(key)));
} | [
"private",
"void",
"integrate",
"(",
"HashMap",
"<",
"String",
",",
"Float",
">",
"state",
")",
"{",
"if",
"(",
"state",
"!=",
"null",
")",
"state",
".",
"keySet",
"(",
")",
".",
"forEach",
"(",
"key",
"->",
"stocks",
".",
"put",
"(",
"key",
",",
... | default stack from JChannel | [
"default",
"stack",
"from",
"JChannel"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/demos/QuoteServer.java#L39-L42 | train |
belaban/JGroups | src/org/jgroups/util/BlockingInputStream.java | BlockingInputStream.sanityCheck | protected static void sanityCheck(byte[] buf, int offset, int length) {
if(buf == null) throw new NullPointerException("buffer is null");
if(offset + length > buf.length)
throw new ArrayIndexOutOfBoundsException("length (" + length + ") + offset (" + offset +
") > buf.length (" + buf.length + ")");
} | java | protected static void sanityCheck(byte[] buf, int offset, int length) {
if(buf == null) throw new NullPointerException("buffer is null");
if(offset + length > buf.length)
throw new ArrayIndexOutOfBoundsException("length (" + length + ") + offset (" + offset +
") > buf.length (" + buf.length + ")");
} | [
"protected",
"static",
"void",
"sanityCheck",
"(",
"byte",
"[",
"]",
"buf",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"if",
"(",
"buf",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"buffer is null\"",
")",
";",
"if",
"(",... | Verifies that length doesn't exceed a buffer's length
@param buf
@param offset
@param length | [
"Verifies",
"that",
"length",
"doesn",
"t",
"exceed",
"a",
"buffer",
"s",
"length"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/BlockingInputStream.java#L260-L265 | train |
belaban/JGroups | src/org/jgroups/auth/X509Token.java | X509Token.setCertificate | public void setCertificate() throws KeyStoreException, IOException, NoSuchAlgorithmException,
CertificateException, NoSuchPaddingException, InvalidKeyException,
IllegalBlockSizeException, BadPaddingException, UnrecoverableEntryException {
KeyStore store = KeyStore.getInstance(this.keystore_type);
InputStream inputStream=Thread.currentThread().getContextClassLoader().getResourceAsStream(this.keystore_path);
if(inputStream == null)
inputStream=new FileInputStream(this.keystore_path);
store.load(inputStream, this.keystore_password);
this.cipher = Cipher.getInstance(this.cipher_type);
this.certificate = (X509Certificate) store.getCertificate(this.cert_alias);
log.debug("certificate = " + this.certificate.toString());
this.cipher.init(Cipher.ENCRYPT_MODE, this.certificate);
this.encryptedToken = this.cipher.doFinal(this.auth_value.getBytes());
KeyStore.PrivateKeyEntry privateKey = (KeyStore.PrivateKeyEntry) store.getEntry(
this.cert_alias, new KeyStore.PasswordProtection(this.cert_password));
this.certPrivateKey = privateKey.getPrivateKey();
this.valueSet=true;
} | java | public void setCertificate() throws KeyStoreException, IOException, NoSuchAlgorithmException,
CertificateException, NoSuchPaddingException, InvalidKeyException,
IllegalBlockSizeException, BadPaddingException, UnrecoverableEntryException {
KeyStore store = KeyStore.getInstance(this.keystore_type);
InputStream inputStream=Thread.currentThread().getContextClassLoader().getResourceAsStream(this.keystore_path);
if(inputStream == null)
inputStream=new FileInputStream(this.keystore_path);
store.load(inputStream, this.keystore_password);
this.cipher = Cipher.getInstance(this.cipher_type);
this.certificate = (X509Certificate) store.getCertificate(this.cert_alias);
log.debug("certificate = " + this.certificate.toString());
this.cipher.init(Cipher.ENCRYPT_MODE, this.certificate);
this.encryptedToken = this.cipher.doFinal(this.auth_value.getBytes());
KeyStore.PrivateKeyEntry privateKey = (KeyStore.PrivateKeyEntry) store.getEntry(
this.cert_alias, new KeyStore.PasswordProtection(this.cert_password));
this.certPrivateKey = privateKey.getPrivateKey();
this.valueSet=true;
} | [
"public",
"void",
"setCertificate",
"(",
")",
"throws",
"KeyStoreException",
",",
"IOException",
",",
"NoSuchAlgorithmException",
",",
"CertificateException",
",",
"NoSuchPaddingException",
",",
"InvalidKeyException",
",",
"IllegalBlockSizeException",
",",
"BadPaddingExceptio... | Used during setup to get the certification from the keystore and encrypt the auth_value with
the private key | [
"Used",
"during",
"setup",
"to",
"get",
"the",
"certification",
"from",
"the",
"keystore",
"and",
"encrypt",
"the",
"auth_value",
"with",
"the",
"private",
"key"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/auth/X509Token.java#L145-L167 | train |
belaban/JGroups | src/org/jgroups/util/Headers.java | Headers.getHeader | public static <T extends Header> T getHeader(final Header[] hdrs, short id) {
if(hdrs == null)
return null;
for(Header hdr: hdrs) {
if(hdr == null)
return null;
if(hdr.getProtId() == id)
return (T)hdr;
}
return null;
} | java | public static <T extends Header> T getHeader(final Header[] hdrs, short id) {
if(hdrs == null)
return null;
for(Header hdr: hdrs) {
if(hdr == null)
return null;
if(hdr.getProtId() == id)
return (T)hdr;
}
return null;
} | [
"public",
"static",
"<",
"T",
"extends",
"Header",
">",
"T",
"getHeader",
"(",
"final",
"Header",
"[",
"]",
"hdrs",
",",
"short",
"id",
")",
"{",
"if",
"(",
"hdrs",
"==",
"null",
")",
"return",
"null",
";",
"for",
"(",
"Header",
"hdr",
":",
"hdrs",... | Returns the header associated with an ID
@param id The ID
@return | [
"Returns",
"the",
"header",
"associated",
"with",
"an",
"ID"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/Headers.java#L39-L49 | train |
belaban/JGroups | src/org/jgroups/util/Headers.java | Headers.putHeader | public static Header[] putHeader(final Header[] headers, short id, Header hdr, boolean replace_if_present) {
int i=0;
Header[] hdrs=headers;
boolean resized=false;
while(i < hdrs.length) {
if(hdrs[i] == null) {
hdrs[i]=hdr;
return resized? hdrs: null;
}
short hdr_id=hdrs[i].getProtId();
if(hdr_id == id) {
if(replace_if_present || hdrs[i] == null)
hdrs[i]=hdr;
return resized? hdrs : null;
}
i++;
if(i >= hdrs.length) {
hdrs=resize(hdrs);
resized=true;
}
}
throw new IllegalStateException("unable to add element " + id + ", index=" + i); // we should never come here
} | java | public static Header[] putHeader(final Header[] headers, short id, Header hdr, boolean replace_if_present) {
int i=0;
Header[] hdrs=headers;
boolean resized=false;
while(i < hdrs.length) {
if(hdrs[i] == null) {
hdrs[i]=hdr;
return resized? hdrs: null;
}
short hdr_id=hdrs[i].getProtId();
if(hdr_id == id) {
if(replace_if_present || hdrs[i] == null)
hdrs[i]=hdr;
return resized? hdrs : null;
}
i++;
if(i >= hdrs.length) {
hdrs=resize(hdrs);
resized=true;
}
}
throw new IllegalStateException("unable to add element " + id + ", index=" + i); // we should never come here
} | [
"public",
"static",
"Header",
"[",
"]",
"putHeader",
"(",
"final",
"Header",
"[",
"]",
"headers",
",",
"short",
"id",
",",
"Header",
"hdr",
",",
"boolean",
"replace_if_present",
")",
"{",
"int",
"i",
"=",
"0",
";",
"Header",
"[",
"]",
"hdrs",
"=",
"h... | Adds hdr at the next available slot. If none is available, the headers array passed in will be copied and the copy
returned
@param headers The headers array
@param id The protocol ID of the header
@param hdr The header
@param replace_if_present Whether or not to overwrite an existing header
@return A new copy of headers if the array needed to be expanded, or null otherwise | [
"Adds",
"hdr",
"at",
"the",
"next",
"available",
"slot",
".",
"If",
"none",
"is",
"available",
"the",
"headers",
"array",
"passed",
"in",
"will",
"be",
"copied",
"and",
"the",
"copy",
"returned"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/Headers.java#L114-L136 | train |
belaban/JGroups | src/org/jgroups/util/Headers.java | Headers.resize | public static Header[] resize(final Header[] headers) {
int new_capacity=headers.length + RESIZE_INCR;
Header[] new_hdrs=new Header[new_capacity];
System.arraycopy(headers, 0, new_hdrs, 0, headers.length);
return new_hdrs;
} | java | public static Header[] resize(final Header[] headers) {
int new_capacity=headers.length + RESIZE_INCR;
Header[] new_hdrs=new Header[new_capacity];
System.arraycopy(headers, 0, new_hdrs, 0, headers.length);
return new_hdrs;
} | [
"public",
"static",
"Header",
"[",
"]",
"resize",
"(",
"final",
"Header",
"[",
"]",
"headers",
")",
"{",
"int",
"new_capacity",
"=",
"headers",
".",
"length",
"+",
"RESIZE_INCR",
";",
"Header",
"[",
"]",
"new_hdrs",
"=",
"new",
"Header",
"[",
"new_capaci... | Increases the capacity of the array and copies the contents of the old into the new array | [
"Increases",
"the",
"capacity",
"of",
"the",
"array",
"and",
"copies",
"the",
"contents",
"of",
"the",
"old",
"into",
"the",
"new",
"array"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/Headers.java#L141-L146 | train |
belaban/JGroups | src/org/jgroups/protocols/RingBufferBundler.java | RingBufferBundler.print | protected static String print(BiConsumer<Integer,Integer> wait_strategy) {
if(wait_strategy == null) return null;
if(wait_strategy == SPIN) return "spin";
else if(wait_strategy == YIELD) return "yield";
else if(wait_strategy == PARK) return "park";
else if(wait_strategy == SPIN_PARK) return "spin-park";
else if(wait_strategy == SPIN_YIELD) return "spin-yield";
else return wait_strategy.getClass().getSimpleName();
} | java | protected static String print(BiConsumer<Integer,Integer> wait_strategy) {
if(wait_strategy == null) return null;
if(wait_strategy == SPIN) return "spin";
else if(wait_strategy == YIELD) return "yield";
else if(wait_strategy == PARK) return "park";
else if(wait_strategy == SPIN_PARK) return "spin-park";
else if(wait_strategy == SPIN_YIELD) return "spin-yield";
else return wait_strategy.getClass().getSimpleName();
} | [
"protected",
"static",
"String",
"print",
"(",
"BiConsumer",
"<",
"Integer",
",",
"Integer",
">",
"wait_strategy",
")",
"{",
"if",
"(",
"wait_strategy",
"==",
"null",
")",
"return",
"null",
";",
"if",
"(",
"wait_strategy",
"==",
"SPIN",
")",
"return",
"\"s... | fast equivalent to % | [
"fast",
"equivalent",
"to",
"%"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/RingBufferBundler.java#L172-L180 | train |
belaban/JGroups | src/org/jgroups/protocols/pbcast/CoordGmsImpl.java | CoordGmsImpl.leave | public void leave(Address mbr) {
if(mbr == null) {
if(log.isErrorEnabled()) log.error(Util.getMessage("MemberSAddressIsNull"));
return;
}
ViewHandler<Request> vh=gms.getViewHandler();
vh.add(new Request(Request.COORD_LEAVE, mbr)); // https://issues.jboss.org/browse/JGRP-2293
// If we're the coord leaving, ignore gms.leave_timeout: https://issues.jboss.org/browse/JGRP-1509
long timeout=(long)(Math.max(gms.leave_timeout, gms.view_ack_collection_timeout) * 1.5);
vh.waitUntilComplete(timeout);
} | java | public void leave(Address mbr) {
if(mbr == null) {
if(log.isErrorEnabled()) log.error(Util.getMessage("MemberSAddressIsNull"));
return;
}
ViewHandler<Request> vh=gms.getViewHandler();
vh.add(new Request(Request.COORD_LEAVE, mbr)); // https://issues.jboss.org/browse/JGRP-2293
// If we're the coord leaving, ignore gms.leave_timeout: https://issues.jboss.org/browse/JGRP-1509
long timeout=(long)(Math.max(gms.leave_timeout, gms.view_ack_collection_timeout) * 1.5);
vh.waitUntilComplete(timeout);
} | [
"public",
"void",
"leave",
"(",
"Address",
"mbr",
")",
"{",
"if",
"(",
"mbr",
"==",
"null",
")",
"{",
"if",
"(",
"log",
".",
"isErrorEnabled",
"(",
")",
")",
"log",
".",
"error",
"(",
"Util",
".",
"getMessage",
"(",
"\"MemberSAddressIsNull\"",
")",
"... | The coordinator itself wants to leave the group | [
"The",
"coordinator",
"itself",
"wants",
"to",
"leave",
"the",
"group"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/pbcast/CoordGmsImpl.java#L47-L57 | train |
belaban/JGroups | src/org/jgroups/protocols/FRAG.java | FRAG.unfragment | private Message unfragment(Message msg, FragHeader hdr) {
Address sender=msg.getSrc();
FragmentationTable frag_table=fragment_list.get(sender);
if(frag_table == null) {
frag_table=new FragmentationTable(sender);
try {
fragment_list.add(sender, frag_table);
}
catch(IllegalArgumentException x) { // the entry has already been added, probably in parallel from another thread
frag_table=fragment_list.get(sender);
}
}
num_received_frags++;
byte[] buf=frag_table.add(hdr.id, hdr.frag_id, hdr.num_frags, msg.getBuffer());
if(buf == null)
return null;
try {
DataInput in=new ByteArrayDataInputStream(buf);
Message assembled_msg=new Message(false);
assembled_msg.readFrom(in);
assembled_msg.setSrc(sender); // needed ? YES, because fragments have a null src !!
if(log.isTraceEnabled()) log.trace("assembled_msg is " + assembled_msg);
num_received_msgs++;
return assembled_msg;
}
catch(Exception e) {
log.error(Util.getMessage("FailedUnfragmentingAMessage"), e);
return null;
}
} | java | private Message unfragment(Message msg, FragHeader hdr) {
Address sender=msg.getSrc();
FragmentationTable frag_table=fragment_list.get(sender);
if(frag_table == null) {
frag_table=new FragmentationTable(sender);
try {
fragment_list.add(sender, frag_table);
}
catch(IllegalArgumentException x) { // the entry has already been added, probably in parallel from another thread
frag_table=fragment_list.get(sender);
}
}
num_received_frags++;
byte[] buf=frag_table.add(hdr.id, hdr.frag_id, hdr.num_frags, msg.getBuffer());
if(buf == null)
return null;
try {
DataInput in=new ByteArrayDataInputStream(buf);
Message assembled_msg=new Message(false);
assembled_msg.readFrom(in);
assembled_msg.setSrc(sender); // needed ? YES, because fragments have a null src !!
if(log.isTraceEnabled()) log.trace("assembled_msg is " + assembled_msg);
num_received_msgs++;
return assembled_msg;
}
catch(Exception e) {
log.error(Util.getMessage("FailedUnfragmentingAMessage"), e);
return null;
}
} | [
"private",
"Message",
"unfragment",
"(",
"Message",
"msg",
",",
"FragHeader",
"hdr",
")",
"{",
"Address",
"sender",
"=",
"msg",
".",
"getSrc",
"(",
")",
";",
"FragmentationTable",
"frag_table",
"=",
"fragment_list",
".",
"get",
"(",
"sender",
")",
";",
"if... | 1. Get all the fragment buffers
2. When all are received -> Assemble them into one big buffer
3. Read headers and byte buffer from big buffer
4. Set headers and buffer in msg
5. Pass msg up the stack | [
"1",
".",
"Get",
"all",
"the",
"fragment",
"buffers",
"2",
".",
"When",
"all",
"are",
"received",
"-",
">",
"Assemble",
"them",
"into",
"one",
"big",
"buffer",
"3",
".",
"Read",
"headers",
"and",
"byte",
"buffer",
"from",
"big",
"buffer",
"4",
".",
"... | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/FRAG.java#L234-L264 | train |
belaban/JGroups | src/org/jgroups/util/NonBlockingCredit.java | NonBlockingCredit.decrementIfEnoughCredits | public boolean decrementIfEnoughCredits(final Message msg, int credits, long timeout) {
lock.lock();
try {
if(queuing)
return addToQueue(msg, credits);
if(decrement(credits))
return true; // enough credits, message will be sent
queuing=true; // not enough credits, start queuing
return addToQueue(msg, credits);
}
finally {
lock.unlock();
}
} | java | public boolean decrementIfEnoughCredits(final Message msg, int credits, long timeout) {
lock.lock();
try {
if(queuing)
return addToQueue(msg, credits);
if(decrement(credits))
return true; // enough credits, message will be sent
queuing=true; // not enough credits, start queuing
return addToQueue(msg, credits);
}
finally {
lock.unlock();
}
} | [
"public",
"boolean",
"decrementIfEnoughCredits",
"(",
"final",
"Message",
"msg",
",",
"int",
"credits",
",",
"long",
"timeout",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"queuing",
")",
"return",
"addToQueue",
"(",
"msg",
",",
... | Decrements the sender's credits by the size of the message.
@param msg The message
@param credits The number of bytes to decrement the credits. Is {@link Message#length()}.
@param timeout Ignored
@return True if the message was sent, false if it was queued | [
"Decrements",
"the",
"sender",
"s",
"credits",
"by",
"the",
"size",
"of",
"the",
"message",
"."
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/NonBlockingCredit.java#L54-L67 | train |
belaban/JGroups | src/org/jgroups/conf/ClassConfigurator.java | ClassConfigurator.add | public static void add(short magic, Class clazz) {
if(magic < MIN_CUSTOM_MAGIC_NUMBER)
throw new IllegalArgumentException("magic ID (" + magic + ") must be >= " + MIN_CUSTOM_MAGIC_NUMBER);
if(magicMapUser.containsKey(magic) || classMap.containsKey(clazz))
alreadyInMagicMap(magic, clazz.getName());
Object inst=null;
try {
inst=clazz.getDeclaredConstructor().newInstance();
}
catch(Exception e) {
throw new IllegalStateException("failed creating instance " + clazz, e);
}
Object val=clazz;
if(Header.class.isAssignableFrom(clazz)) { // class is a header
checkSameId((Header)inst, magic);
val=((Header)inst).create();
}
if(Constructable.class.isAssignableFrom(clazz)) {
val=((Constructable)inst).create();
inst=((Supplier<?>)val).get();
if(!inst.getClass().equals(clazz))
throw new IllegalStateException(String.format("%s.create() returned the wrong class: %s\n",
clazz.getSimpleName(), inst.getClass().getSimpleName()));
}
magicMapUser.put(magic, val);
classMap.put(clazz, magic);
} | java | public static void add(short magic, Class clazz) {
if(magic < MIN_CUSTOM_MAGIC_NUMBER)
throw new IllegalArgumentException("magic ID (" + magic + ") must be >= " + MIN_CUSTOM_MAGIC_NUMBER);
if(magicMapUser.containsKey(magic) || classMap.containsKey(clazz))
alreadyInMagicMap(magic, clazz.getName());
Object inst=null;
try {
inst=clazz.getDeclaredConstructor().newInstance();
}
catch(Exception e) {
throw new IllegalStateException("failed creating instance " + clazz, e);
}
Object val=clazz;
if(Header.class.isAssignableFrom(clazz)) { // class is a header
checkSameId((Header)inst, magic);
val=((Header)inst).create();
}
if(Constructable.class.isAssignableFrom(clazz)) {
val=((Constructable)inst).create();
inst=((Supplier<?>)val).get();
if(!inst.getClass().equals(clazz))
throw new IllegalStateException(String.format("%s.create() returned the wrong class: %s\n",
clazz.getSimpleName(), inst.getClass().getSimpleName()));
}
magicMapUser.put(magic, val);
classMap.put(clazz, magic);
} | [
"public",
"static",
"void",
"add",
"(",
"short",
"magic",
",",
"Class",
"clazz",
")",
"{",
"if",
"(",
"magic",
"<",
"MIN_CUSTOM_MAGIC_NUMBER",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"magic ID (\"",
"+",
"magic",
"+",
"\") must be >= \"",
"+",
... | Method to register a user-defined header with jg-magic-map at runtime
@param magic The magic number. Needs to be > 1024
@param clazz The class. Usually a subclass of Header
@throws IllegalArgumentException If the magic number is already taken, or the magic number is <= 1024 | [
"Method",
"to",
"register",
"a",
"user",
"-",
"defined",
"header",
"with",
"jg",
"-",
"magic",
"-",
"map",
"at",
"runtime"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/conf/ClassConfigurator.java#L71-L101 | train |
belaban/JGroups | src/org/jgroups/conf/ClassConfigurator.java | ClassConfigurator.get | public static Class get(String clazzname, ClassLoader loader) throws ClassNotFoundException {
return Util.loadClass(clazzname, loader != null? loader : ClassConfigurator.class.getClassLoader());
} | java | public static Class get(String clazzname, ClassLoader loader) throws ClassNotFoundException {
return Util.loadClass(clazzname, loader != null? loader : ClassConfigurator.class.getClassLoader());
} | [
"public",
"static",
"Class",
"get",
"(",
"String",
"clazzname",
",",
"ClassLoader",
"loader",
")",
"throws",
"ClassNotFoundException",
"{",
"return",
"Util",
".",
"loadClass",
"(",
"clazzname",
",",
"loader",
"!=",
"null",
"?",
"loader",
":",
"ClassConfigurator"... | Loads and returns the class from the class name
@param clazzname a fully classified class name to be loaded
@return a Class object that represents a class that implements java.io.Externalizable | [
"Loads",
"and",
"returns",
"the",
"class",
"from",
"the",
"class",
"name"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/conf/ClassConfigurator.java#L142-L144 | train |
belaban/JGroups | src/org/jgroups/conf/ClassConfigurator.java | ClassConfigurator.getMagicNumber | public static short getMagicNumber(Class clazz) {
Short i=classMap.get(clazz);
if(i == null)
return -1;
else
return i;
} | java | public static short getMagicNumber(Class clazz) {
Short i=classMap.get(clazz);
if(i == null)
return -1;
else
return i;
} | [
"public",
"static",
"short",
"getMagicNumber",
"(",
"Class",
"clazz",
")",
"{",
"Short",
"i",
"=",
"classMap",
".",
"get",
"(",
"clazz",
")",
";",
"if",
"(",
"i",
"==",
"null",
")",
"return",
"-",
"1",
";",
"else",
"return",
"i",
";",
"}"
] | Returns the magic number for the class.
@param clazz a class object that we want the magic number for
@return the magic number for a class, -1 if no mapping is available | [
"Returns",
"the",
"magic",
"number",
"for",
"the",
"class",
"."
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/conf/ClassConfigurator.java#L156-L162 | train |
belaban/JGroups | src/org/jgroups/protocols/pbcast/Merger.java | Merger.merge | public void merge(Map<Address, View> views) {
if(views == null || views.isEmpty()) {
log.warn("the views passed with the MERGE event were empty (or null); ignoring MERGE event");
return;
}
if(View.sameViews(views.values())) {
log.debug("MERGE event is ignored because of identical views: %s", Util.printListWithDelimiter(views.values(), ", "));
return;
}
if(isMergeInProgress()) {
log.trace("%s: merge is already running (merge_id=%s)", gms.local_addr, merge_id);
return;
}
Address merge_leader=determineMergeLeader(views);
if(merge_leader == null)
return;
if(merge_leader.equals(gms.local_addr)) {
log.debug("%s: I will be the merge leader. Starting the merge task. Views: %s", gms.local_addr, views);
merge_task.start(views);
}
else
log.trace("%s: I'm not the merge leader, waiting for merge leader (%s) to start merge", gms.local_addr, merge_leader);
} | java | public void merge(Map<Address, View> views) {
if(views == null || views.isEmpty()) {
log.warn("the views passed with the MERGE event were empty (or null); ignoring MERGE event");
return;
}
if(View.sameViews(views.values())) {
log.debug("MERGE event is ignored because of identical views: %s", Util.printListWithDelimiter(views.values(), ", "));
return;
}
if(isMergeInProgress()) {
log.trace("%s: merge is already running (merge_id=%s)", gms.local_addr, merge_id);
return;
}
Address merge_leader=determineMergeLeader(views);
if(merge_leader == null)
return;
if(merge_leader.equals(gms.local_addr)) {
log.debug("%s: I will be the merge leader. Starting the merge task. Views: %s", gms.local_addr, views);
merge_task.start(views);
}
else
log.trace("%s: I'm not the merge leader, waiting for merge leader (%s) to start merge", gms.local_addr, merge_leader);
} | [
"public",
"void",
"merge",
"(",
"Map",
"<",
"Address",
",",
"View",
">",
"views",
")",
"{",
"if",
"(",
"views",
"==",
"null",
"||",
"views",
".",
"isEmpty",
"(",
")",
")",
"{",
"log",
".",
"warn",
"(",
"\"the views passed with the MERGE event were empty (o... | Invoked upon receiving a MERGE event from the MERGE layer. Starts the merge protocol.
See description of protocol in DESIGN.
@param views A List of <em>different</em> views detected by the merge protocol, keyed by sender | [
"Invoked",
"upon",
"receiving",
"a",
"MERGE",
"event",
"from",
"the",
"MERGE",
"layer",
".",
"Starts",
"the",
"merge",
"protocol",
".",
"See",
"description",
"of",
"protocol",
"in",
"DESIGN",
"."
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/pbcast/Merger.java#L75-L101 | train |
belaban/JGroups | src/org/jgroups/protocols/pbcast/Merger.java | Merger.determineMergeLeader | protected Address determineMergeLeader(Map<Address,View> views) {
// we need the merge *coordinators* not merge participants because not everyone can lead a merge !
Collection<Address> coords=Util.determineActualMergeCoords(views);
if(coords.isEmpty())
coords=Util.determineMergeCoords(views); // https://issues.jboss.org/browse/JGRP-2092
if(coords.isEmpty()) {
log.error("%s: unable to determine merge leader from %s; not starting a merge", gms.local_addr, views);
return null;
}
return new Membership(coords).sort().elementAt(0); // establish a deterministic order, so that coords can elect leader
} | java | protected Address determineMergeLeader(Map<Address,View> views) {
// we need the merge *coordinators* not merge participants because not everyone can lead a merge !
Collection<Address> coords=Util.determineActualMergeCoords(views);
if(coords.isEmpty())
coords=Util.determineMergeCoords(views); // https://issues.jboss.org/browse/JGRP-2092
if(coords.isEmpty()) {
log.error("%s: unable to determine merge leader from %s; not starting a merge", gms.local_addr, views);
return null;
}
return new Membership(coords).sort().elementAt(0); // establish a deterministic order, so that coords can elect leader
} | [
"protected",
"Address",
"determineMergeLeader",
"(",
"Map",
"<",
"Address",
",",
"View",
">",
"views",
")",
"{",
"// we need the merge *coordinators* not merge participants because not everyone can lead a merge !",
"Collection",
"<",
"Address",
">",
"coords",
"=",
"Util",
"... | Returns the address of the merge leader | [
"Returns",
"the",
"address",
"of",
"the",
"merge",
"leader"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/pbcast/Merger.java#L222-L232 | train |
belaban/JGroups | src/org/jgroups/protocols/pbcast/Merger.java | Merger.sendMergeResponse | protected void sendMergeResponse(Address sender, View view, Digest digest, MergeId merge_id) {
Message msg=new Message(sender).setBuffer(GMS.marshal(view, digest)).setFlag(Message.Flag.OOB,Message.Flag.INTERNAL)
.putHeader(gms.getId(), new GMS.GmsHeader(GMS.GmsHeader.MERGE_RSP).mergeId(merge_id));
gms.getDownProtocol().down(msg);
} | java | protected void sendMergeResponse(Address sender, View view, Digest digest, MergeId merge_id) {
Message msg=new Message(sender).setBuffer(GMS.marshal(view, digest)).setFlag(Message.Flag.OOB,Message.Flag.INTERNAL)
.putHeader(gms.getId(), new GMS.GmsHeader(GMS.GmsHeader.MERGE_RSP).mergeId(merge_id));
gms.getDownProtocol().down(msg);
} | [
"protected",
"void",
"sendMergeResponse",
"(",
"Address",
"sender",
",",
"View",
"view",
",",
"Digest",
"digest",
",",
"MergeId",
"merge_id",
")",
"{",
"Message",
"msg",
"=",
"new",
"Message",
"(",
"sender",
")",
".",
"setBuffer",
"(",
"GMS",
".",
"marshal... | Send back a response containing view and digest to sender | [
"Send",
"back",
"a",
"response",
"containing",
"view",
"and",
"digest",
"to",
"sender"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/pbcast/Merger.java#L300-L304 | train |
belaban/JGroups | src/org/jgroups/protocols/pbcast/Merger.java | Merger.sendMergeView | protected void sendMergeView(Collection<Address> coords, MergeData combined_merge_data, MergeId merge_id) {
if(coords == null || coords.isEmpty() || combined_merge_data == null)
return;
View view=combined_merge_data.view;
Digest digest=combined_merge_data.digest;
if(view == null || digest == null) {
log.error(Util.getMessage("ViewOrDigestIsNullCannotSendConsolidatedMergeView/Digest"));
return;
}
int size=0;
if(gms.flushProtocolInStack) {
gms.merge_ack_collector.reset(coords);
size=gms.merge_ack_collector.size();
}
Event install_merge_view_evt=new Event(Event.INSTALL_MERGE_VIEW, view);
gms.getUpProtocol().up(install_merge_view_evt);
gms.getDownProtocol().down(install_merge_view_evt);
long start=System.currentTimeMillis();
for(Address coord: coords) {
Message msg=new Message(coord).setBuffer(GMS.marshal(view, digest))
.putHeader(gms.getId(),new GMS.GmsHeader(GMS.GmsHeader.INSTALL_MERGE_VIEW).mergeId(merge_id));
gms.getDownProtocol().down(msg);
}
//[JGRP-700] - FLUSH: flushing should span merge; if flush is in stack, wait for acks from subview coordinators
if(gms.flushProtocolInStack) {
try {
gms.merge_ack_collector.waitForAllAcks(gms.view_ack_collection_timeout);
log.trace("%s: received all ACKs (%d) for merge view %s in %d ms",
gms.local_addr, size, view, (System.currentTimeMillis() - start));
}
catch(TimeoutException e) {
log.warn("%s: failed to collect all ACKs (%d) for merge view %s after %d ms, missing ACKs from %s",
gms.local_addr, size, view, gms.view_ack_collection_timeout, gms.merge_ack_collector.printMissing());
}
}
} | java | protected void sendMergeView(Collection<Address> coords, MergeData combined_merge_data, MergeId merge_id) {
if(coords == null || coords.isEmpty() || combined_merge_data == null)
return;
View view=combined_merge_data.view;
Digest digest=combined_merge_data.digest;
if(view == null || digest == null) {
log.error(Util.getMessage("ViewOrDigestIsNullCannotSendConsolidatedMergeView/Digest"));
return;
}
int size=0;
if(gms.flushProtocolInStack) {
gms.merge_ack_collector.reset(coords);
size=gms.merge_ack_collector.size();
}
Event install_merge_view_evt=new Event(Event.INSTALL_MERGE_VIEW, view);
gms.getUpProtocol().up(install_merge_view_evt);
gms.getDownProtocol().down(install_merge_view_evt);
long start=System.currentTimeMillis();
for(Address coord: coords) {
Message msg=new Message(coord).setBuffer(GMS.marshal(view, digest))
.putHeader(gms.getId(),new GMS.GmsHeader(GMS.GmsHeader.INSTALL_MERGE_VIEW).mergeId(merge_id));
gms.getDownProtocol().down(msg);
}
//[JGRP-700] - FLUSH: flushing should span merge; if flush is in stack, wait for acks from subview coordinators
if(gms.flushProtocolInStack) {
try {
gms.merge_ack_collector.waitForAllAcks(gms.view_ack_collection_timeout);
log.trace("%s: received all ACKs (%d) for merge view %s in %d ms",
gms.local_addr, size, view, (System.currentTimeMillis() - start));
}
catch(TimeoutException e) {
log.warn("%s: failed to collect all ACKs (%d) for merge view %s after %d ms, missing ACKs from %s",
gms.local_addr, size, view, gms.view_ack_collection_timeout, gms.merge_ack_collector.printMissing());
}
}
} | [
"protected",
"void",
"sendMergeView",
"(",
"Collection",
"<",
"Address",
">",
"coords",
",",
"MergeData",
"combined_merge_data",
",",
"MergeId",
"merge_id",
")",
"{",
"if",
"(",
"coords",
"==",
"null",
"||",
"coords",
".",
"isEmpty",
"(",
")",
"||",
"combine... | Sends the new view and digest to all subgroup coordinators. Each coord will in turn broadcast the new view and
digest to all the members of its subgroup | [
"Sends",
"the",
"new",
"view",
"and",
"digest",
"to",
"all",
"subgroup",
"coordinators",
".",
"Each",
"coord",
"will",
"in",
"turn",
"broadcast",
"the",
"new",
"view",
"and",
"digest",
"to",
"all",
"the",
"members",
"of",
"its",
"subgroup"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/pbcast/Merger.java#L310-L350 | train |
belaban/JGroups | src/org/jgroups/protocols/pbcast/Merger.java | Merger.fixDigests | protected void fixDigests() {
Digest digest=fetchDigestsFromAllMembersInSubPartition(gms.view, null);
Message msg=new Message().putHeader(gms.getId(), new GMS.GmsHeader(GMS.GmsHeader.INSTALL_DIGEST))
.setBuffer(GMS.marshal(null, digest));
gms.getDownProtocol().down(msg);
} | java | protected void fixDigests() {
Digest digest=fetchDigestsFromAllMembersInSubPartition(gms.view, null);
Message msg=new Message().putHeader(gms.getId(), new GMS.GmsHeader(GMS.GmsHeader.INSTALL_DIGEST))
.setBuffer(GMS.marshal(null, digest));
gms.getDownProtocol().down(msg);
} | [
"protected",
"void",
"fixDigests",
"(",
")",
"{",
"Digest",
"digest",
"=",
"fetchDigestsFromAllMembersInSubPartition",
"(",
"gms",
".",
"view",
",",
"null",
")",
";",
"Message",
"msg",
"=",
"new",
"Message",
"(",
")",
".",
"putHeader",
"(",
"gms",
".",
"ge... | Fetches the digests from all members and installs them again. Used only for diagnosis and support; don't
use this otherwise ! | [
"Fetches",
"the",
"digests",
"from",
"all",
"members",
"and",
"installs",
"them",
"again",
".",
"Used",
"only",
"for",
"diagnosis",
"and",
"support",
";",
"don",
"t",
"use",
"this",
"otherwise",
"!"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/pbcast/Merger.java#L416-L421 | train |
belaban/JGroups | src/org/jgroups/util/MutableDigest.java | MutableDigest.allSet | public boolean allSet() {
for(int i=0; i < seqnos.length; i+=2)
if(seqnos[i] == -1)
return false;
return true;
} | java | public boolean allSet() {
for(int i=0; i < seqnos.length; i+=2)
if(seqnos[i] == -1)
return false;
return true;
} | [
"public",
"boolean",
"allSet",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"seqnos",
".",
"length",
";",
"i",
"+=",
"2",
")",
"if",
"(",
"seqnos",
"[",
"i",
"]",
"==",
"-",
"1",
")",
"return",
"false",
";",
"return",
"true... | Returns true if all members have a corresponding seqno >= 0, else false | [
"Returns",
"true",
"if",
"all",
"members",
"have",
"a",
"corresponding",
"seqno",
">",
"=",
"0",
"else",
"false"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/MutableDigest.java#L37-L42 | train |
belaban/JGroups | src/org/jgroups/util/MutableDigest.java | MutableDigest.getNonSetMembers | public Address[] getNonSetMembers() {
Address[] retval=new Address[countNonSetMembers()];
if(retval.length == 0)
return retval;
int index=0;
for(int i=0; i < members.length; i++)
if(seqnos[i*2] == -1)
retval[index++]=members[i];
return retval;
} | java | public Address[] getNonSetMembers() {
Address[] retval=new Address[countNonSetMembers()];
if(retval.length == 0)
return retval;
int index=0;
for(int i=0; i < members.length; i++)
if(seqnos[i*2] == -1)
retval[index++]=members[i];
return retval;
} | [
"public",
"Address",
"[",
"]",
"getNonSetMembers",
"(",
")",
"{",
"Address",
"[",
"]",
"retval",
"=",
"new",
"Address",
"[",
"countNonSetMembers",
"(",
")",
"]",
";",
"if",
"(",
"retval",
".",
"length",
"==",
"0",
")",
"return",
"retval",
";",
"int",
... | Returns an array of members whose seqno is not set. Returns an empty array if all are set. | [
"Returns",
"an",
"array",
"of",
"members",
"whose",
"seqno",
"is",
"not",
"set",
".",
"Returns",
"an",
"empty",
"array",
"if",
"all",
"are",
"set",
"."
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/MutableDigest.java#L45-L54 | train |
belaban/JGroups | src/org/jgroups/util/RequestTable.java | RequestTable.add | public long add(T element) {
lock.lock();
try {
long next=high+1;
if(next - low > capacity())
_grow(next-low);
int high_index=index(high);
buffer[high_index]=element;
return high++;
}
finally {
lock.unlock();
}
} | java | public long add(T element) {
lock.lock();
try {
long next=high+1;
if(next - low > capacity())
_grow(next-low);
int high_index=index(high);
buffer[high_index]=element;
return high++;
}
finally {
lock.unlock();
}
} | [
"public",
"long",
"add",
"(",
"T",
"element",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"long",
"next",
"=",
"high",
"+",
"1",
";",
"if",
"(",
"next",
"-",
"low",
">",
"capacity",
"(",
")",
")",
"_grow",
"(",
"next",
"-",
"low... | Adds a new element and returns the sequence number at which it was inserted. Advances the high
pointer and grows the buffer if needed.
@param element the element to be added. Must not be null or an exception will be thrown
@return the seqno at which element was added | [
"Adds",
"a",
"new",
"element",
"and",
"returns",
"the",
"sequence",
"number",
"at",
"which",
"it",
"was",
"inserted",
".",
"Advances",
"the",
"high",
"pointer",
"and",
"grows",
"the",
"buffer",
"if",
"needed",
"."
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/RequestTable.java#L58-L71 | train |
belaban/JGroups | src/org/jgroups/util/RequestTable.java | RequestTable.remove | public T remove(long seqno) {
lock.lock();
try {
if(seqno < low || seqno > high)
return null;
int index=index(seqno);
T retval=buffer[index];
if(retval != null && removes_till_compaction > 0)
num_removes++;
buffer[index]=null;
if(seqno == low)
advanceLow();
if(removes_till_compaction > 0 && num_removes >= removes_till_compaction) {
_compact();
num_removes=0;
}
return retval;
}
finally {
lock.unlock();
}
} | java | public T remove(long seqno) {
lock.lock();
try {
if(seqno < low || seqno > high)
return null;
int index=index(seqno);
T retval=buffer[index];
if(retval != null && removes_till_compaction > 0)
num_removes++;
buffer[index]=null;
if(seqno == low)
advanceLow();
if(removes_till_compaction > 0 && num_removes >= removes_till_compaction) {
_compact();
num_removes=0;
}
return retval;
}
finally {
lock.unlock();
}
} | [
"public",
"T",
"remove",
"(",
"long",
"seqno",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"seqno",
"<",
"low",
"||",
"seqno",
">",
"high",
")",
"return",
"null",
";",
"int",
"index",
"=",
"index",
"(",
"seqno",
")",
";... | Removes the element at the index matching seqno. If seqno == low, tries to advance low until a non-null element
is encountered, up to high
@param seqno
@return | [
"Removes",
"the",
"element",
"at",
"the",
"index",
"matching",
"seqno",
".",
"If",
"seqno",
"==",
"low",
"tries",
"to",
"advance",
"low",
"until",
"a",
"non",
"-",
"null",
"element",
"is",
"encountered",
"up",
"to",
"high"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/RequestTable.java#L91-L112 | train |
belaban/JGroups | src/org/jgroups/util/RequestTable.java | RequestTable.grow | public RequestTable<T> grow(int new_capacity) {
lock.lock();
try {
_grow(new_capacity);
return this;
}
finally {
lock.unlock();
}
} | java | public RequestTable<T> grow(int new_capacity) {
lock.lock();
try {
_grow(new_capacity);
return this;
}
finally {
lock.unlock();
}
} | [
"public",
"RequestTable",
"<",
"T",
">",
"grow",
"(",
"int",
"new_capacity",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"_grow",
"(",
"new_capacity",
")",
";",
"return",
"this",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
"... | Grows the array to at least new_capacity. This method is mainly used for testing and is not typically called
directly, but indirectly when adding elements and the underlying array has no space left.
@param new_capacity the new capacity of the underlying array. Will be rounded up to the nearest power of 2 value.
A value smaller than the current capacity is ignored. | [
"Grows",
"the",
"array",
"to",
"at",
"least",
"new_capacity",
".",
"This",
"method",
"is",
"mainly",
"used",
"for",
"testing",
"and",
"is",
"not",
"typically",
"called",
"directly",
"but",
"indirectly",
"when",
"adding",
"elements",
"and",
"the",
"underlying",... | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/RequestTable.java#L221-L230 | train |
belaban/JGroups | src/org/jgroups/util/RequestTable.java | RequestTable._compact | @GuardedBy("lock")
protected boolean _compact() {
int new_cap=buffer.length >> 1; // needs to be a power of 2 for efficient modulo operation, e.g. for index()
// boolean compactable=this.buffer.length > 0 && (size() <= new_cap || (contiguousSpaceAvailable=_contiguousSpaceAvailable(new_cap)));
boolean compactable=this.buffer.length > 0 && high-low <= new_cap;
if(!compactable)
return false; // not enough space to shrink the buffer to half its size
_copy(new_cap);
return true;
} | java | @GuardedBy("lock")
protected boolean _compact() {
int new_cap=buffer.length >> 1; // needs to be a power of 2 for efficient modulo operation, e.g. for index()
// boolean compactable=this.buffer.length > 0 && (size() <= new_cap || (contiguousSpaceAvailable=_contiguousSpaceAvailable(new_cap)));
boolean compactable=this.buffer.length > 0 && high-low <= new_cap;
if(!compactable)
return false; // not enough space to shrink the buffer to half its size
_copy(new_cap);
return true;
} | [
"@",
"GuardedBy",
"(",
"\"lock\"",
")",
"protected",
"boolean",
"_compact",
"(",
")",
"{",
"int",
"new_cap",
"=",
"buffer",
".",
"length",
">>",
"1",
";",
"// needs to be a power of 2 for efficient modulo operation, e.g. for index()",
"// boolean compactable=this.buffer.len... | Shrinks the array to half of its current size if the current number of elements fit into half of the capacity.
@return true if the compaction succeeded, else false (e.g. when the current elements would not fit) | [
"Shrinks",
"the",
"array",
"to",
"half",
"of",
"its",
"current",
"size",
"if",
"the",
"current",
"number",
"of",
"elements",
"fit",
"into",
"half",
"of",
"the",
"capacity",
"."
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/RequestTable.java#L289-L298 | train |
belaban/JGroups | src/org/jgroups/util/RequestTable.java | RequestTable._copy | protected void _copy(int new_cap) {
// copy elements from [low to high-1] into new indices in new array
T[] new_buf=(T[])new Object[new_cap];
int new_len=new_buf.length;
int old_len=this.buffer.length;
for(long i=low, num_iterations=0; i < high && num_iterations < old_len; i++, num_iterations++) {
int old_index=index(i, old_len);
if(this.buffer[old_index] != null) {
int new_index=index(i, new_len);
new_buf[new_index]=this.buffer[old_index];
}
}
this.buffer=new_buf;
} | java | protected void _copy(int new_cap) {
// copy elements from [low to high-1] into new indices in new array
T[] new_buf=(T[])new Object[new_cap];
int new_len=new_buf.length;
int old_len=this.buffer.length;
for(long i=low, num_iterations=0; i < high && num_iterations < old_len; i++, num_iterations++) {
int old_index=index(i, old_len);
if(this.buffer[old_index] != null) {
int new_index=index(i, new_len);
new_buf[new_index]=this.buffer[old_index];
}
}
this.buffer=new_buf;
} | [
"protected",
"void",
"_copy",
"(",
"int",
"new_cap",
")",
"{",
"// copy elements from [low to high-1] into new indices in new array",
"T",
"[",
"]",
"new_buf",
"=",
"(",
"T",
"[",
"]",
")",
"new",
"Object",
"[",
"new_cap",
"]",
";",
"int",
"new_len",
"=",
"new... | Copies elements from old into new array | [
"Copies",
"elements",
"from",
"old",
"into",
"new",
"array"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/RequestTable.java#L323-L337 | train |
belaban/JGroups | src/org/jgroups/util/SizeBoundedQueue.java | SizeBoundedQueue.remove | public T remove() {
lock.lock();
try {
if(queue.isEmpty())
return null;
El<T> el=queue.poll();
count-=el.size;
not_full.signalAll();
return el.el;
}
finally {
lock.unlock();
}
} | java | public T remove() {
lock.lock();
try {
if(queue.isEmpty())
return null;
El<T> el=queue.poll();
count-=el.size;
not_full.signalAll();
return el.el;
}
finally {
lock.unlock();
}
} | [
"public",
"T",
"remove",
"(",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"queue",
".",
"isEmpty",
"(",
")",
")",
"return",
"null",
";",
"El",
"<",
"T",
">",
"el",
"=",
"queue",
".",
"poll",
"(",
")",
";",
"count",
... | Removes and returns the first element or null if the queue is empty | [
"Removes",
"and",
"returns",
"the",
"first",
"element",
"or",
"null",
"if",
"the",
"queue",
"is",
"empty"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/SizeBoundedQueue.java#L67-L81 | train |
belaban/JGroups | src/org/jgroups/protocols/tom/SenderManager.java | SenderManager.addNewMessageToSend | public void addNewMessageToSend(MessageID messageID, Collection<Address> destinations, long initialSequenceNumber,
boolean deliverToMyself) {
MessageInfo messageInfo = new MessageInfo(destinations, initialSequenceNumber, deliverToMyself);
if (deliverToMyself) {
messageInfo.setProposeReceived(messageID.getAddress());
}
sentMessages.put(messageID, messageInfo);
} | java | public void addNewMessageToSend(MessageID messageID, Collection<Address> destinations, long initialSequenceNumber,
boolean deliverToMyself) {
MessageInfo messageInfo = new MessageInfo(destinations, initialSequenceNumber, deliverToMyself);
if (deliverToMyself) {
messageInfo.setProposeReceived(messageID.getAddress());
}
sentMessages.put(messageID, messageInfo);
} | [
"public",
"void",
"addNewMessageToSend",
"(",
"MessageID",
"messageID",
",",
"Collection",
"<",
"Address",
">",
"destinations",
",",
"long",
"initialSequenceNumber",
",",
"boolean",
"deliverToMyself",
")",
"{",
"MessageInfo",
"messageInfo",
"=",
"new",
"MessageInfo",
... | Add a new message sent
@param messageID the message ID
@param destinations the destination set
@param initialSequenceNumber the initial sequence number
@param deliverToMyself true if *this* member is in destination sent, false otherwise | [
"Add",
"a",
"new",
"message",
"sent"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/tom/SenderManager.java#L28-L35 | train |
belaban/JGroups | src/org/jgroups/protocols/tom/SenderManager.java | SenderManager.addPropose | public long addPropose(MessageID messageID, Address from, long sequenceNumber) {
MessageInfo messageInfo = sentMessages.get(messageID);
if (messageInfo != null && messageInfo.addPropose(from, sequenceNumber)) {
return messageInfo.getAndMarkFinalSent();
}
return NOT_READY;
} | java | public long addPropose(MessageID messageID, Address from, long sequenceNumber) {
MessageInfo messageInfo = sentMessages.get(messageID);
if (messageInfo != null && messageInfo.addPropose(from, sequenceNumber)) {
return messageInfo.getAndMarkFinalSent();
}
return NOT_READY;
} | [
"public",
"long",
"addPropose",
"(",
"MessageID",
"messageID",
",",
"Address",
"from",
",",
"long",
"sequenceNumber",
")",
"{",
"MessageInfo",
"messageInfo",
"=",
"sentMessages",
".",
"get",
"(",
"messageID",
")",
";",
"if",
"(",
"messageInfo",
"!=",
"null",
... | Add a propose from a member in destination set
@param messageID the message ID
@param from the originator of the propose
@param sequenceNumber the proposed sequence number
@return NOT_READY if the final sequence number is not know, or the final sequence number | [
"Add",
"a",
"propose",
"from",
"a",
"member",
"in",
"destination",
"set"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/tom/SenderManager.java#L44-L50 | train |
belaban/JGroups | src/org/jgroups/protocols/tom/SenderManager.java | SenderManager.markSent | public boolean markSent(MessageID messageID) {
MessageInfo messageInfo = sentMessages.remove(messageID);
return messageInfo != null && messageInfo.toSelfDeliver;
} | java | public boolean markSent(MessageID messageID) {
MessageInfo messageInfo = sentMessages.remove(messageID);
return messageInfo != null && messageInfo.toSelfDeliver;
} | [
"public",
"boolean",
"markSent",
"(",
"MessageID",
"messageID",
")",
"{",
"MessageInfo",
"messageInfo",
"=",
"sentMessages",
".",
"remove",
"(",
"messageID",
")",
";",
"return",
"messageInfo",
"!=",
"null",
"&&",
"messageInfo",
".",
"toSelfDeliver",
";",
"}"
] | Mark the message as sent
@param messageID the message ID
@return return true if *this* member is in destination set | [
"Mark",
"the",
"message",
"as",
"sent"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/tom/SenderManager.java#L57-L60 | train |
belaban/JGroups | src/org/jgroups/protocols/tom/SenderManager.java | SenderManager.getDestination | public Set<Address> getDestination(MessageID messageID) {
MessageInfo messageInfo = sentMessages.get(messageID);
Set<Address> destination;
if (messageInfo != null) {
destination = new HashSet<>(messageInfo.destinations);
} else {
destination = Collections.emptySet();
}
return destination;
} | java | public Set<Address> getDestination(MessageID messageID) {
MessageInfo messageInfo = sentMessages.get(messageID);
Set<Address> destination;
if (messageInfo != null) {
destination = new HashSet<>(messageInfo.destinations);
} else {
destination = Collections.emptySet();
}
return destination;
} | [
"public",
"Set",
"<",
"Address",
">",
"getDestination",
"(",
"MessageID",
"messageID",
")",
"{",
"MessageInfo",
"messageInfo",
"=",
"sentMessages",
".",
"get",
"(",
"messageID",
")",
";",
"Set",
"<",
"Address",
">",
"destination",
";",
"if",
"(",
"messageInf... | obtains the destination set of a message
@param messageID the message ID
@return the destination set | [
"obtains",
"the",
"destination",
"set",
"of",
"a",
"message"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/tom/SenderManager.java#L67-L76 | train |
belaban/JGroups | src/org/jgroups/util/Average.java | Average.merge | public <T extends Average> T merge(T other) {
if(Util.productGreaterThan(count, (long)Math.ceil(avg), Long.MAX_VALUE) ||
Util.productGreaterThan(other.count(), (long)Math.ceil(other.average()), Long.MAX_VALUE)) {
// the above computation is not correct as the sum of the 2 products can still lead to overflow
// a non-weighted avg
avg=avg + other.average() / 2.0;
}
else { // compute the new average weighted by count
long total_count=count + other.count();
avg=(count * avg + other.count() * other.average()) / total_count;
count=total_count/2;
}
return (T)this;
} | java | public <T extends Average> T merge(T other) {
if(Util.productGreaterThan(count, (long)Math.ceil(avg), Long.MAX_VALUE) ||
Util.productGreaterThan(other.count(), (long)Math.ceil(other.average()), Long.MAX_VALUE)) {
// the above computation is not correct as the sum of the 2 products can still lead to overflow
// a non-weighted avg
avg=avg + other.average() / 2.0;
}
else { // compute the new average weighted by count
long total_count=count + other.count();
avg=(count * avg + other.count() * other.average()) / total_count;
count=total_count/2;
}
return (T)this;
} | [
"public",
"<",
"T",
"extends",
"Average",
">",
"T",
"merge",
"(",
"T",
"other",
")",
"{",
"if",
"(",
"Util",
".",
"productGreaterThan",
"(",
"count",
",",
"(",
"long",
")",
"Math",
".",
"ceil",
"(",
"avg",
")",
",",
"Long",
".",
"MAX_VALUE",
")",
... | Merges this average with another one | [
"Merges",
"this",
"average",
"with",
"another",
"one"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/Average.java#L36-L49 | train |
belaban/JGroups | src/org/jgroups/util/SeqnoRange.java | SeqnoRange.getBits | public Collection<Range> getBits(boolean value) {
int index=0;
int start_range=0, end_range=0;
int size=(int)((high - low) + 1);
final Collection<Range> retval=new ArrayList<>(size);
while(index < size) {
start_range=value? bits.nextSetBit(index) : bits.nextClearBit(index);
if(start_range < 0 || start_range >= size)
break;
end_range=value? bits.nextClearBit(start_range) : bits.nextSetBit(start_range);
if(end_range < 0 || end_range >= size) {
retval.add(new Range(start_range + low, size-1+low));
break;
}
retval.add(new Range(start_range + low, end_range-1+low));
index=end_range;
}
return retval;
} | java | public Collection<Range> getBits(boolean value) {
int index=0;
int start_range=0, end_range=0;
int size=(int)((high - low) + 1);
final Collection<Range> retval=new ArrayList<>(size);
while(index < size) {
start_range=value? bits.nextSetBit(index) : bits.nextClearBit(index);
if(start_range < 0 || start_range >= size)
break;
end_range=value? bits.nextClearBit(start_range) : bits.nextSetBit(start_range);
if(end_range < 0 || end_range >= size) {
retval.add(new Range(start_range + low, size-1+low));
break;
}
retval.add(new Range(start_range + low, end_range-1+low));
index=end_range;
}
return retval;
} | [
"public",
"Collection",
"<",
"Range",
">",
"getBits",
"(",
"boolean",
"value",
")",
"{",
"int",
"index",
"=",
"0",
";",
"int",
"start_range",
"=",
"0",
",",
"end_range",
"=",
"0",
";",
"int",
"size",
"=",
"(",
"int",
")",
"(",
"(",
"high",
"-",
"... | Returns ranges of all bit set to value
@param value If true, returns all bits set to 1, else 0
@return | [
"Returns",
"ranges",
"of",
"all",
"bit",
"set",
"to",
"value"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/SeqnoRange.java#L115-L135 | train |
belaban/JGroups | src/org/jgroups/protocols/rules/SUPERVISOR.java | SUPERVISOR.installRule | public void installRule(String name, long interval, Rule rule) {
rule.supervisor(this).log(log).init();
Future<?> future=timer.scheduleAtFixedRate(rule, interval, interval, TimeUnit.MILLISECONDS);
Tuple<Rule,Future<?>> existing=rules.put(name != null? name : rule.name(), new Tuple<>(rule, future));
if(existing != null)
existing.getVal2().cancel(true);
} | java | public void installRule(String name, long interval, Rule rule) {
rule.supervisor(this).log(log).init();
Future<?> future=timer.scheduleAtFixedRate(rule, interval, interval, TimeUnit.MILLISECONDS);
Tuple<Rule,Future<?>> existing=rules.put(name != null? name : rule.name(), new Tuple<>(rule, future));
if(existing != null)
existing.getVal2().cancel(true);
} | [
"public",
"void",
"installRule",
"(",
"String",
"name",
",",
"long",
"interval",
",",
"Rule",
"rule",
")",
"{",
"rule",
".",
"supervisor",
"(",
"this",
")",
".",
"log",
"(",
"log",
")",
".",
"init",
"(",
")",
";",
"Future",
"<",
"?",
">",
"future",... | Installs a new rule
@param name The name of the rule
@param interval Number of ms between executions of the rule
@param rule The rule | [
"Installs",
"a",
"new",
"rule"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/rules/SUPERVISOR.java#L139-L145 | train |
belaban/JGroups | src/org/jgroups/protocols/pbcast/STATE_TRANSFER.java | STATE_TRANSFER.handleStateRsp | protected void handleStateRsp(final Digest digest, Address sender, byte[] state) {
try {
if(isDigestNeeded()) {
punchHoleFor(sender);
closeBarrierAndSuspendStable(); // fix for https://jira.jboss.org/jira/browse/JGRP-1013
if(digest != null)
down_prot.down(new Event(Event.OVERWRITE_DIGEST, digest)); // set the digest (e.g. in NAKACK)
}
waiting_for_state_response=false;
stop=System.currentTimeMillis();
log.debug("%s: received state, size=%s, time=%d milliseconds", local_addr,
(state == null? "0" : Util.printBytes(state.length)), stop - start);
StateTransferResult result=new StateTransferResult(state);
up_prot.up(new Event(Event.GET_STATE_OK, result));
down_prot.down(new Event(Event.GET_VIEW_FROM_COORD)); // https://issues.jboss.org/browse/JGRP-1751
}
catch(Throwable t) {
handleException(t);
}
finally {
if(isDigestNeeded()) {
closeHoleFor(sender);
openBarrierAndResumeStable();
}
}
} | java | protected void handleStateRsp(final Digest digest, Address sender, byte[] state) {
try {
if(isDigestNeeded()) {
punchHoleFor(sender);
closeBarrierAndSuspendStable(); // fix for https://jira.jboss.org/jira/browse/JGRP-1013
if(digest != null)
down_prot.down(new Event(Event.OVERWRITE_DIGEST, digest)); // set the digest (e.g. in NAKACK)
}
waiting_for_state_response=false;
stop=System.currentTimeMillis();
log.debug("%s: received state, size=%s, time=%d milliseconds", local_addr,
(state == null? "0" : Util.printBytes(state.length)), stop - start);
StateTransferResult result=new StateTransferResult(state);
up_prot.up(new Event(Event.GET_STATE_OK, result));
down_prot.down(new Event(Event.GET_VIEW_FROM_COORD)); // https://issues.jboss.org/browse/JGRP-1751
}
catch(Throwable t) {
handleException(t);
}
finally {
if(isDigestNeeded()) {
closeHoleFor(sender);
openBarrierAndResumeStable();
}
}
} | [
"protected",
"void",
"handleStateRsp",
"(",
"final",
"Digest",
"digest",
",",
"Address",
"sender",
",",
"byte",
"[",
"]",
"state",
")",
"{",
"try",
"{",
"if",
"(",
"isDigestNeeded",
"(",
")",
")",
"{",
"punchHoleFor",
"(",
"sender",
")",
";",
"closeBarri... | Set the digest and the send the state up to the application | [
"Set",
"the",
"digest",
"and",
"the",
"send",
"the",
"state",
"up",
"to",
"the",
"application"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/pbcast/STATE_TRANSFER.java#L358-L383 | train |
belaban/JGroups | src/org/jgroups/protocols/RingBufferBundlerLockless.java | RingBufferBundlerLockless.advanceWriteIndex | protected int advanceWriteIndex() {
int num=0, start=write_index;
for(;;) {
if(buf[start] == null)
break;
num++;
start=index(start+1);
if(start == tmp_write_index.get())
break;
}
write_index=start;
return num;
} | java | protected int advanceWriteIndex() {
int num=0, start=write_index;
for(;;) {
if(buf[start] == null)
break;
num++;
start=index(start+1);
if(start == tmp_write_index.get())
break;
}
write_index=start;
return num;
} | [
"protected",
"int",
"advanceWriteIndex",
"(",
")",
"{",
"int",
"num",
"=",
"0",
",",
"start",
"=",
"write_index",
";",
"for",
"(",
";",
";",
")",
"{",
"if",
"(",
"buf",
"[",
"start",
"]",
"==",
"null",
")",
"break",
";",
"num",
"++",
";",
"start"... | Advance write_index up to tmp_write_index as long as no null msg is found | [
"Advance",
"write_index",
"up",
"to",
"tmp_write_index",
"as",
"long",
"as",
"no",
"null",
"msg",
"is",
"found"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/RingBufferBundlerLockless.java#L132-L144 | train |
belaban/JGroups | src/org/jgroups/demos/TotalOrder.java | MyCanvas.drawEmptyBoard | void drawEmptyBoard(Graphics g) {
int x=x_offset, y=y_offset;
Color old_col=g.getColor();
g.setFont(def_font2);
old_col=g.getColor();
g.setColor(checksum_col);
g.drawString(("Checksum: " + checksum), x_offset + field_size, y_offset - 20);
g.setFont(def_font);
g.setColor(old_col);
for(int i=0; i < num_fields; i++) {
for(int j=0; j < num_fields; j++) { // draws 1 row
g.drawRect(x, y, field_size, field_size);
x+=field_size;
}
g.drawString((String.valueOf((num_fields - i - 1))), x + 20, y + field_size / 2);
y+=field_size;
x=x_offset;
}
for(int i=0; i < num_fields; i++) {
g.drawString((String.valueOf(i)), x_offset + i * field_size + field_size / 2, y + 30);
}
} | java | void drawEmptyBoard(Graphics g) {
int x=x_offset, y=y_offset;
Color old_col=g.getColor();
g.setFont(def_font2);
old_col=g.getColor();
g.setColor(checksum_col);
g.drawString(("Checksum: " + checksum), x_offset + field_size, y_offset - 20);
g.setFont(def_font);
g.setColor(old_col);
for(int i=0; i < num_fields; i++) {
for(int j=0; j < num_fields; j++) { // draws 1 row
g.drawRect(x, y, field_size, field_size);
x+=field_size;
}
g.drawString((String.valueOf((num_fields - i - 1))), x + 20, y + field_size / 2);
y+=field_size;
x=x_offset;
}
for(int i=0; i < num_fields; i++) {
g.drawString((String.valueOf(i)), x_offset + i * field_size + field_size / 2, y + 30);
}
} | [
"void",
"drawEmptyBoard",
"(",
"Graphics",
"g",
")",
"{",
"int",
"x",
"=",
"x_offset",
",",
"y",
"=",
"y_offset",
";",
"Color",
"old_col",
"=",
"g",
".",
"getColor",
"(",
")",
";",
"g",
".",
"setFont",
"(",
"def_font2",
")",
";",
"old_col",
"=",
"g... | Draws the empty board, no pieces on it yet, just grid lines | [
"Draws",
"the",
"empty",
"board",
"no",
"pieces",
"on",
"it",
"yet",
"just",
"grid",
"lines"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/demos/TotalOrder.java#L626-L650 | train |
belaban/JGroups | src/org/jgroups/protocols/pbcast/FLUSH.java | FLUSH.onSuspend | private void onSuspend(final List<Address> members) {
Message msg = null;
Collection<Address> participantsInFlush = null;
synchronized (sharedLock) {
flushCoordinator = localAddress;
// start FLUSH only on group members that we need to flush
participantsInFlush = members;
participantsInFlush.retainAll(currentView.getMembers());
flushMembers.clear();
flushMembers.addAll(participantsInFlush);
flushMembers.removeAll(suspected);
msg = new Message(null).src(localAddress).setBuffer(marshal(participantsInFlush, null))
.putHeader(this.id, new FlushHeader(FlushHeader.START_FLUSH, currentViewId()));
}
if (participantsInFlush.isEmpty()) {
flush_promise.setResult(SUCCESS_START_FLUSH);
} else {
down_prot.down(msg);
if (log.isDebugEnabled())
log.debug(localAddress + ": flush coordinator "
+ " is starting FLUSH with participants " + participantsInFlush);
}
} | java | private void onSuspend(final List<Address> members) {
Message msg = null;
Collection<Address> participantsInFlush = null;
synchronized (sharedLock) {
flushCoordinator = localAddress;
// start FLUSH only on group members that we need to flush
participantsInFlush = members;
participantsInFlush.retainAll(currentView.getMembers());
flushMembers.clear();
flushMembers.addAll(participantsInFlush);
flushMembers.removeAll(suspected);
msg = new Message(null).src(localAddress).setBuffer(marshal(participantsInFlush, null))
.putHeader(this.id, new FlushHeader(FlushHeader.START_FLUSH, currentViewId()));
}
if (participantsInFlush.isEmpty()) {
flush_promise.setResult(SUCCESS_START_FLUSH);
} else {
down_prot.down(msg);
if (log.isDebugEnabled())
log.debug(localAddress + ": flush coordinator "
+ " is starting FLUSH with participants " + participantsInFlush);
}
} | [
"private",
"void",
"onSuspend",
"(",
"final",
"List",
"<",
"Address",
">",
"members",
")",
"{",
"Message",
"msg",
"=",
"null",
";",
"Collection",
"<",
"Address",
">",
"participantsInFlush",
"=",
"null",
";",
"synchronized",
"(",
"sharedLock",
")",
"{",
"fl... | Starts the flush protocol
@param members List of participants in the flush protocol. Guaranteed to be non-null | [
"Starts",
"the",
"flush",
"protocol"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/pbcast/FLUSH.java#L688-L713 | train |
belaban/JGroups | src/org/jgroups/protocols/pbcast/FLUSH.java | FLUSH.maxSeqnos | protected static Digest maxSeqnos(final View view, List<Digest> digests) {
if(view == null || digests == null)
return null;
MutableDigest digest=new MutableDigest(view.getMembersRaw());
digests.forEach(digest::merge);
return digest;
} | java | protected static Digest maxSeqnos(final View view, List<Digest> digests) {
if(view == null || digests == null)
return null;
MutableDigest digest=new MutableDigest(view.getMembersRaw());
digests.forEach(digest::merge);
return digest;
} | [
"protected",
"static",
"Digest",
"maxSeqnos",
"(",
"final",
"View",
"view",
",",
"List",
"<",
"Digest",
">",
"digests",
")",
"{",
"if",
"(",
"view",
"==",
"null",
"||",
"digests",
"==",
"null",
")",
"return",
"null",
";",
"MutableDigest",
"digest",
"=",
... | Returns a digest which contains, for all members of view, the highest delivered and received
seqno of all digests | [
"Returns",
"a",
"digest",
"which",
"contains",
"for",
"all",
"members",
"of",
"view",
"the",
"highest",
"delivered",
"and",
"received",
"seqno",
"of",
"all",
"digests"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/pbcast/FLUSH.java#L872-L879 | train |
belaban/JGroups | src/org/jgroups/stack/LargestWinningPolicy.java | LargestWinningPolicy.getNewMembership | public List<Address> getNewMembership(final Collection<Collection<Address>> subviews) {
ArrayList<Collection<Address>> aSubviews=new ArrayList<>(subviews);
int sLargest = 0;
int iLargest = 0;
for (int i = 0; i < aSubviews.size(); i++) {
int size = aSubviews.get(i).size();
if (size > sLargest) {
sLargest = size;
iLargest = i;
}
}
Membership mbrs = new Membership(aSubviews.get(iLargest));
for (int i = 0; i < aSubviews.size(); i++)
if (i != iLargest)
mbrs.add(aSubviews.get(i));
return mbrs.getMembers();
} | java | public List<Address> getNewMembership(final Collection<Collection<Address>> subviews) {
ArrayList<Collection<Address>> aSubviews=new ArrayList<>(subviews);
int sLargest = 0;
int iLargest = 0;
for (int i = 0; i < aSubviews.size(); i++) {
int size = aSubviews.get(i).size();
if (size > sLargest) {
sLargest = size;
iLargest = i;
}
}
Membership mbrs = new Membership(aSubviews.get(iLargest));
for (int i = 0; i < aSubviews.size(); i++)
if (i != iLargest)
mbrs.add(aSubviews.get(i));
return mbrs.getMembers();
} | [
"public",
"List",
"<",
"Address",
">",
"getNewMembership",
"(",
"final",
"Collection",
"<",
"Collection",
"<",
"Address",
">",
">",
"subviews",
")",
"{",
"ArrayList",
"<",
"Collection",
"<",
"Address",
">>",
"aSubviews",
"=",
"new",
"ArrayList",
"<>",
"(",
... | Called when a merge happened. The largest subview wins. | [
"Called",
"when",
"a",
"merge",
"happened",
".",
"The",
"largest",
"subview",
"wins",
"."
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/stack/LargestWinningPolicy.java#L22-L41 | train |
belaban/JGroups | src/org/jgroups/blocks/cs/TcpConnection.java | TcpConnection.sendLocalAddress | protected void sendLocalAddress(Address local_addr) throws Exception {
try {
// write the cookie
out.write(cookie, 0, cookie.length);
// write the version
out.writeShort(Version.version);
out.writeShort(local_addr.serializedSize()); // address size
local_addr.writeTo(out);
out.flush(); // needed ?
updateLastAccessed();
}
catch(Exception ex) {
server.socket_factory.close(this.sock);
connected=false;
throw ex;
}
} | java | protected void sendLocalAddress(Address local_addr) throws Exception {
try {
// write the cookie
out.write(cookie, 0, cookie.length);
// write the version
out.writeShort(Version.version);
out.writeShort(local_addr.serializedSize()); // address size
local_addr.writeTo(out);
out.flush(); // needed ?
updateLastAccessed();
}
catch(Exception ex) {
server.socket_factory.close(this.sock);
connected=false;
throw ex;
}
} | [
"protected",
"void",
"sendLocalAddress",
"(",
"Address",
"local_addr",
")",
"throws",
"Exception",
"{",
"try",
"{",
"// write the cookie",
"out",
".",
"write",
"(",
"cookie",
",",
"0",
",",
"cookie",
".",
"length",
")",
";",
"// write the version",
"out",
".",... | Send the cookie first, then the our port number. If the cookie
doesn't match the receiver's cookie, the receiver will reject the
connection and close it. | [
"Send",
"the",
"cookie",
"first",
"then",
"the",
"our",
"port",
"number",
".",
"If",
"the",
"cookie",
"doesn",
"t",
"match",
"the",
"receiver",
"s",
"cookie",
"the",
"receiver",
"will",
"reject",
"the",
"connection",
"and",
"close",
"it",
"."
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/blocks/cs/TcpConnection.java#L215-L232 | train |
belaban/JGroups | src/org/jgroups/blocks/cs/TcpConnection.java | TcpConnection.readPeerAddress | protected Address readPeerAddress(Socket client_sock) throws Exception {
int timeout=client_sock.getSoTimeout();
client_sock.setSoTimeout(server.peerAddressReadTimeout());
try {
// read the cookie first
byte[] input_cookie=new byte[cookie.length];
in.readFully(input_cookie, 0, input_cookie.length);
if(!Arrays.equals(cookie, input_cookie))
throw new SocketException(String.format("%s: BaseServer.TcpConnection.readPeerAddress(): cookie sent by " +
"%s:%d does not match own cookie; terminating connection",
server.localAddress(), client_sock.getInetAddress(), client_sock.getPort()));
// then read the version
short version=in.readShort();
if(!Version.isBinaryCompatible(version))
throw new IOException("packet from " + client_sock.getInetAddress() + ":" + client_sock.getPort() +
" has different version (" + Version.print(version) +
") from ours (" + Version.printVersion() + "); discarding it");
in.readShort(); // address length is only needed by NioConnection
Address client_peer_addr=new IpAddress();
client_peer_addr.readFrom(in);
updateLastAccessed();
return client_peer_addr;
}
finally {
client_sock.setSoTimeout(timeout);
}
} | java | protected Address readPeerAddress(Socket client_sock) throws Exception {
int timeout=client_sock.getSoTimeout();
client_sock.setSoTimeout(server.peerAddressReadTimeout());
try {
// read the cookie first
byte[] input_cookie=new byte[cookie.length];
in.readFully(input_cookie, 0, input_cookie.length);
if(!Arrays.equals(cookie, input_cookie))
throw new SocketException(String.format("%s: BaseServer.TcpConnection.readPeerAddress(): cookie sent by " +
"%s:%d does not match own cookie; terminating connection",
server.localAddress(), client_sock.getInetAddress(), client_sock.getPort()));
// then read the version
short version=in.readShort();
if(!Version.isBinaryCompatible(version))
throw new IOException("packet from " + client_sock.getInetAddress() + ":" + client_sock.getPort() +
" has different version (" + Version.print(version) +
") from ours (" + Version.printVersion() + "); discarding it");
in.readShort(); // address length is only needed by NioConnection
Address client_peer_addr=new IpAddress();
client_peer_addr.readFrom(in);
updateLastAccessed();
return client_peer_addr;
}
finally {
client_sock.setSoTimeout(timeout);
}
} | [
"protected",
"Address",
"readPeerAddress",
"(",
"Socket",
"client_sock",
")",
"throws",
"Exception",
"{",
"int",
"timeout",
"=",
"client_sock",
".",
"getSoTimeout",
"(",
")",
";",
"client_sock",
".",
"setSoTimeout",
"(",
"server",
".",
"peerAddressReadTimeout",
"(... | Reads the peer's address. First a cookie has to be sent which has to
match my own cookie, otherwise the connection will be refused | [
"Reads",
"the",
"peer",
"s",
"address",
".",
"First",
"a",
"cookie",
"has",
"to",
"be",
"sent",
"which",
"has",
"to",
"match",
"my",
"own",
"cookie",
"otherwise",
"the",
"connection",
"will",
"be",
"refused"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/blocks/cs/TcpConnection.java#L238-L266 | train |
belaban/JGroups | src/org/jgroups/jmx/JmxConfigurator.java | JmxConfigurator.unregister | public static void unregister(MBeanServer server, String object_name) throws Exception {
Set<ObjectName> mbeans = server.queryNames(new ObjectName(object_name), null);
if(mbeans != null)
for (ObjectName name: mbeans)
server.unregisterMBean(name);
} | java | public static void unregister(MBeanServer server, String object_name) throws Exception {
Set<ObjectName> mbeans = server.queryNames(new ObjectName(object_name), null);
if(mbeans != null)
for (ObjectName name: mbeans)
server.unregisterMBean(name);
} | [
"public",
"static",
"void",
"unregister",
"(",
"MBeanServer",
"server",
",",
"String",
"object_name",
")",
"throws",
"Exception",
"{",
"Set",
"<",
"ObjectName",
">",
"mbeans",
"=",
"server",
".",
"queryNames",
"(",
"new",
"ObjectName",
"(",
"object_name",
")",... | Unregisters object_name and everything under it
@param object_name | [
"Unregisters",
"object_name",
"and",
"everything",
"under",
"it"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/jmx/JmxConfigurator.java#L224-L229 | train |
belaban/JGroups | src/org/jgroups/Channel.java | Channel.send | public void send(Address dst, byte[] buf, int offset, int length) throws Exception {
ch.send(dst, buf, offset, length);
} | java | public void send(Address dst, byte[] buf, int offset, int length) throws Exception {
ch.send(dst, buf, offset, length);
} | [
"public",
"void",
"send",
"(",
"Address",
"dst",
",",
"byte",
"[",
"]",
"buf",
",",
"int",
"offset",
",",
"int",
"length",
")",
"throws",
"Exception",
"{",
"ch",
".",
"send",
"(",
"dst",
",",
"buf",
",",
"offset",
",",
"length",
")",
";",
"}"
] | Sends a message to a destination.
@param dst
The destination address. If null, the message will be sent to all cluster nodes (=
group members)
@param buf
The buffer to be sent
@param offset
The offset into the buffer
@param length
The length of the data to be sent. Has to be <= buf.length - offset. This will send
<code>length</code> bytes starting at <code>offset</code>
@throws Exception
If send() failed | [
"Sends",
"a",
"message",
"to",
"a",
"destination",
"."
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/Channel.java#L263-L265 | train |
belaban/JGroups | src/org/jgroups/Channel.java | Channel.down | public Object down(Event evt) {
if(evt.type() == 1) // MSG
return ch.down((Message)evt.getArg());
return ch.down(evt);
} | java | public Object down(Event evt) {
if(evt.type() == 1) // MSG
return ch.down((Message)evt.getArg());
return ch.down(evt);
} | [
"public",
"Object",
"down",
"(",
"Event",
"evt",
")",
"{",
"if",
"(",
"evt",
".",
"type",
"(",
")",
"==",
"1",
")",
"// MSG",
"return",
"ch",
".",
"down",
"(",
"(",
"Message",
")",
"evt",
".",
"getArg",
"(",
")",
")",
";",
"return",
"ch",
".",
... | Enables access to event mechanism of a channel and is normally not used by clients directly.
@param evt sends an Event to a specific protocol layer and receives a response.
@return a response from a particular protocol layer targeted by Event parameter | [
"Enables",
"access",
"to",
"event",
"mechanism",
"of",
"a",
"channel",
"and",
"is",
"normally",
"not",
"used",
"by",
"clients",
"directly",
"."
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/Channel.java#L274-L278 | train |
belaban/JGroups | src/org/jgroups/util/SuppressCache.java | SuppressCache.putIfAbsent | public Value putIfAbsent(T key, long expiry_time) {
if(key == null)
key=NULL_KEY;
Value val=map.get(key);
if(val == null) {
val=new Value();
Value existing=map.putIfAbsent(key, val);
if(existing == null)
return val;
val=existing;
}
// key already exists
if(val.update().age() > expiry_time) {
map.remove(key);
map.putIfAbsent(key, new Value());
return val;
}
return null;
} | java | public Value putIfAbsent(T key, long expiry_time) {
if(key == null)
key=NULL_KEY;
Value val=map.get(key);
if(val == null) {
val=new Value();
Value existing=map.putIfAbsent(key, val);
if(existing == null)
return val;
val=existing;
}
// key already exists
if(val.update().age() > expiry_time) {
map.remove(key);
map.putIfAbsent(key, new Value());
return val;
}
return null;
} | [
"public",
"Value",
"putIfAbsent",
"(",
"T",
"key",
",",
"long",
"expiry_time",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"key",
"=",
"NULL_KEY",
";",
"Value",
"val",
"=",
"map",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"val",
"==",
"null... | Adds a new key to the hashmap, or updates the Value associated with the existing key if present. If expiry_time
is greater than the age of the Value, the key will be removed.
@param key The key
@param expiry_time Expiry time (in ms)
@return Null if the key was present and not expired, or the Value associated with the existing key
(its count incremented) | [
"Adds",
"a",
"new",
"key",
"to",
"the",
"hashmap",
"or",
"updates",
"the",
"Value",
"associated",
"with",
"the",
"existing",
"key",
"if",
"present",
".",
"If",
"expiry_time",
"is",
"greater",
"than",
"the",
"age",
"of",
"the",
"Value",
"the",
"key",
"wil... | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/SuppressCache.java#L29-L47 | train |
belaban/JGroups | src/org/jgroups/util/SuppressCache.java | SuppressCache.size | public int size() {
int count=0;
for(Value val: map.values())
count+=val.count();
return count;
} | java | public int size() {
int count=0;
for(Value val: map.values())
count+=val.count();
return count;
} | [
"public",
"int",
"size",
"(",
")",
"{",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"Value",
"val",
":",
"map",
".",
"values",
"(",
")",
")",
"count",
"+=",
"val",
".",
"count",
"(",
")",
";",
"return",
"count",
";",
"}"
] | Returns the total count of all values | [
"Returns",
"the",
"total",
"count",
"of",
"all",
"values"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/SuppressCache.java#L66-L72 | train |
belaban/JGroups | src/org/jgroups/util/SuppressLog.java | SuppressLog.log | public void log(Level level, T key, long timeout, Object ... args) {
SuppressCache.Value val=cache.putIfAbsent(key, timeout);
if(val == null) // key is present and hasn't expired
return;
String message=val.count() == 1? String.format(message_format, args) :
String.format(message_format, args) + " " + String.format(suppress_format, val.count(), key, val.age());
switch(level) {
case error:
log.error(message);
break;
case warn:
log.warn(message);
break;
case trace:
log.trace(message);
break;
}
} | java | public void log(Level level, T key, long timeout, Object ... args) {
SuppressCache.Value val=cache.putIfAbsent(key, timeout);
if(val == null) // key is present and hasn't expired
return;
String message=val.count() == 1? String.format(message_format, args) :
String.format(message_format, args) + " " + String.format(suppress_format, val.count(), key, val.age());
switch(level) {
case error:
log.error(message);
break;
case warn:
log.warn(message);
break;
case trace:
log.trace(message);
break;
}
} | [
"public",
"void",
"log",
"(",
"Level",
"level",
",",
"T",
"key",
",",
"long",
"timeout",
",",
"Object",
"...",
"args",
")",
"{",
"SuppressCache",
".",
"Value",
"val",
"=",
"cache",
".",
"putIfAbsent",
"(",
"key",
",",
"timeout",
")",
";",
"if",
"(",
... | Logs a message from a given member if is hasn't been logged for timeout ms
@param level The level, either warn or error
@param key The key into the SuppressCache
@param timeout The timeout
@param args The arguments to the message key | [
"Logs",
"a",
"message",
"from",
"a",
"given",
"member",
"if",
"is",
"hasn",
"t",
"been",
"logged",
"for",
"timeout",
"ms"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/SuppressLog.java#L34-L53 | train |
belaban/JGroups | src/org/jgroups/blocks/Cache.java | Cache.enableReaping | @ManagedOperation
public void enableReaping(long interval) {
if(task != null)
task.cancel(false);
task=timer.scheduleWithFixedDelay(new Reaper(), 0, interval, TimeUnit.MILLISECONDS);
} | java | @ManagedOperation
public void enableReaping(long interval) {
if(task != null)
task.cancel(false);
task=timer.scheduleWithFixedDelay(new Reaper(), 0, interval, TimeUnit.MILLISECONDS);
} | [
"@",
"ManagedOperation",
"public",
"void",
"enableReaping",
"(",
"long",
"interval",
")",
"{",
"if",
"(",
"task",
"!=",
"null",
")",
"task",
".",
"cancel",
"(",
"false",
")",
";",
"task",
"=",
"timer",
".",
"scheduleWithFixedDelay",
"(",
"new",
"Reaper",
... | Runs the reaper every interval ms, evicts expired items | [
"Runs",
"the",
"reaper",
"every",
"interval",
"ms",
"evicts",
"expired",
"items"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/blocks/Cache.java#L67-L72 | train |
belaban/JGroups | src/org/jgroups/util/MessageBatch.java | MessageBatch.add | public int add(final Message msg, boolean resize) {
if(msg == null) return 0;
if(index >= messages.length) {
if(!resize)
return 0;
resize();
}
messages[index++]=msg;
return 1;
} | java | public int add(final Message msg, boolean resize) {
if(msg == null) return 0;
if(index >= messages.length) {
if(!resize)
return 0;
resize();
}
messages[index++]=msg;
return 1;
} | [
"public",
"int",
"add",
"(",
"final",
"Message",
"msg",
",",
"boolean",
"resize",
")",
"{",
"if",
"(",
"msg",
"==",
"null",
")",
"return",
"0",
";",
"if",
"(",
"index",
">=",
"messages",
".",
"length",
")",
"{",
"if",
"(",
"!",
"resize",
")",
"re... | Adds a message to the table
@param msg the message
@param resize whether or not to resize the table. If true, the method will always return 1
@return always 1 if resize==true, else 1 if the message was added or 0 if not | [
"Adds",
"a",
"message",
"to",
"the",
"table"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/MessageBatch.java#L136-L145 | train |
belaban/JGroups | src/org/jgroups/util/MessageBatch.java | MessageBatch.add | public int add(final MessageBatch batch, boolean resize) {
if(batch == null) return 0;
if(this == batch)
throw new IllegalArgumentException("cannot add batch to itself");
int batch_size=batch.size();
if(index+batch_size >= messages.length && resize)
resize(messages.length + batch_size + 1);
int cnt=0;
for(Message msg: batch) {
if(index >= messages.length)
return cnt;
messages[index++]=msg;
cnt++;
}
return cnt;
} | java | public int add(final MessageBatch batch, boolean resize) {
if(batch == null) return 0;
if(this == batch)
throw new IllegalArgumentException("cannot add batch to itself");
int batch_size=batch.size();
if(index+batch_size >= messages.length && resize)
resize(messages.length + batch_size + 1);
int cnt=0;
for(Message msg: batch) {
if(index >= messages.length)
return cnt;
messages[index++]=msg;
cnt++;
}
return cnt;
} | [
"public",
"int",
"add",
"(",
"final",
"MessageBatch",
"batch",
",",
"boolean",
"resize",
")",
"{",
"if",
"(",
"batch",
"==",
"null",
")",
"return",
"0",
";",
"if",
"(",
"this",
"==",
"batch",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"canno... | Adds another batch to this one
@param batch the batch to add to this batch
@param resize when true, this batch will be resized to accommodate the other batch
@return the number of messages from the other batch that were added successfully. Will always be batch.size()
unless resize==0: in this case, the number of messages that were added successfully is returned | [
"Adds",
"another",
"batch",
"to",
"this",
"one"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/MessageBatch.java#L159-L175 | train |
belaban/JGroups | src/org/jgroups/util/MessageBatch.java | MessageBatch.replace | public MessageBatch replace(Message existing_msg, Message new_msg) {
if(existing_msg == null)
return this;
for(int i=0; i < index; i++) {
if(messages[i] != null && messages[i] == existing_msg) {
messages[i]=new_msg;
break;
}
}
return this;
} | java | public MessageBatch replace(Message existing_msg, Message new_msg) {
if(existing_msg == null)
return this;
for(int i=0; i < index; i++) {
if(messages[i] != null && messages[i] == existing_msg) {
messages[i]=new_msg;
break;
}
}
return this;
} | [
"public",
"MessageBatch",
"replace",
"(",
"Message",
"existing_msg",
",",
"Message",
"new_msg",
")",
"{",
"if",
"(",
"existing_msg",
"==",
"null",
")",
"return",
"this",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"index",
";",
"i",
"++",
"... | Replaces a message in the batch with another one
@param existing_msg The message to be replaced. The message has to be non-null and is found by identity (==)
comparison
@param new_msg The message to replace the existing message with, can be null
@return | [
"Replaces",
"a",
"message",
"in",
"the",
"batch",
"with",
"another",
"one"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/MessageBatch.java#L184-L194 | train |
belaban/JGroups | src/org/jgroups/util/MessageBatch.java | MessageBatch.replace | public MessageBatch replace(Predicate<Message> filter, Message replacement, boolean match_all) {
replaceIf(filter, replacement, match_all);
return this;
} | java | public MessageBatch replace(Predicate<Message> filter, Message replacement, boolean match_all) {
replaceIf(filter, replacement, match_all);
return this;
} | [
"public",
"MessageBatch",
"replace",
"(",
"Predicate",
"<",
"Message",
">",
"filter",
",",
"Message",
"replacement",
",",
"boolean",
"match_all",
")",
"{",
"replaceIf",
"(",
"filter",
",",
"replacement",
",",
"match_all",
")",
";",
"return",
"this",
";",
"}"... | Replaces all messages which match a given filter with a replacement message
@param filter the filter. If null, no changes take place. Note that filter needs to be able to handle null msgs
@param replacement the replacement message. Can be null, which essentially removes all messages matching filter
@param match_all whether to replace the first or all matches
@return the MessageBatch | [
"Replaces",
"all",
"messages",
"which",
"match",
"a",
"given",
"filter",
"with",
"a",
"replacement",
"message"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/MessageBatch.java#L203-L206 | train |
belaban/JGroups | src/org/jgroups/util/MessageBatch.java | MessageBatch.replaceIf | public int replaceIf(Predicate<Message> filter, Message replacement, boolean match_all) {
if(filter == null)
return 0;
int matched=0;
for(int i=0; i < index; i++) {
if(filter.test(messages[i])) {
messages[i]=replacement;
matched++;
if(!match_all)
break;
}
}
return matched;
} | java | public int replaceIf(Predicate<Message> filter, Message replacement, boolean match_all) {
if(filter == null)
return 0;
int matched=0;
for(int i=0; i < index; i++) {
if(filter.test(messages[i])) {
messages[i]=replacement;
matched++;
if(!match_all)
break;
}
}
return matched;
} | [
"public",
"int",
"replaceIf",
"(",
"Predicate",
"<",
"Message",
">",
"filter",
",",
"Message",
"replacement",
",",
"boolean",
"match_all",
")",
"{",
"if",
"(",
"filter",
"==",
"null",
")",
"return",
"0",
";",
"int",
"matched",
"=",
"0",
";",
"for",
"("... | Replaces all messages that match a given filter with a replacement message
@param filter the filter. If null, no changes take place. Note that filter needs to be able to handle null msgs
@param replacement the replacement message. Can be null, which essentially removes all messages matching filter
@param match_all whether to replace the first or all matches
@return the number of matched messages | [
"Replaces",
"all",
"messages",
"that",
"match",
"a",
"given",
"filter",
"with",
"a",
"replacement",
"message"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/MessageBatch.java#L215-L228 | train |
belaban/JGroups | src/org/jgroups/util/MessageBatch.java | MessageBatch.transferFrom | public int transferFrom(MessageBatch other, boolean clear) {
if(other == null || this == other)
return 0;
int capacity=messages.length, other_size=other.size();
if(other_size == 0)
return 0;
if(capacity < other_size)
messages=new Message[other_size];
System.arraycopy(other.messages, 0, this.messages, 0, other_size);
if(this.index > other_size)
for(int i=other_size; i < this.index; i++)
messages[i]=null;
this.index=other_size;
if(clear)
other.clear();
return other_size;
} | java | public int transferFrom(MessageBatch other, boolean clear) {
if(other == null || this == other)
return 0;
int capacity=messages.length, other_size=other.size();
if(other_size == 0)
return 0;
if(capacity < other_size)
messages=new Message[other_size];
System.arraycopy(other.messages, 0, this.messages, 0, other_size);
if(this.index > other_size)
for(int i=other_size; i < this.index; i++)
messages[i]=null;
this.index=other_size;
if(clear)
other.clear();
return other_size;
} | [
"public",
"int",
"transferFrom",
"(",
"MessageBatch",
"other",
",",
"boolean",
"clear",
")",
"{",
"if",
"(",
"other",
"==",
"null",
"||",
"this",
"==",
"other",
")",
"return",
"0",
";",
"int",
"capacity",
"=",
"messages",
".",
"length",
",",
"other_size"... | Transfers messages from other to this batch. Optionally clears the other batch after the transfer
@param other the other batch
@param clear If true, the transferred messages are removed from the other batch
@return the number of transferred messages (may be 0 if the other batch was empty) | [
"Transfers",
"messages",
"from",
"other",
"to",
"this",
"batch",
".",
"Optionally",
"clears",
"the",
"other",
"batch",
"after",
"the",
"transfer"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/MessageBatch.java#L236-L252 | train |
belaban/JGroups | src/org/jgroups/util/MessageBatch.java | MessageBatch.getMatchingMessages | public Collection<Message> getMatchingMessages(final short id, boolean remove) {
return map((msg, batch) -> {
if(msg != null && msg.getHeader(id) != null) {
if(remove)
batch.remove(msg);
return msg;
}
return null;
});
} | java | public Collection<Message> getMatchingMessages(final short id, boolean remove) {
return map((msg, batch) -> {
if(msg != null && msg.getHeader(id) != null) {
if(remove)
batch.remove(msg);
return msg;
}
return null;
});
} | [
"public",
"Collection",
"<",
"Message",
">",
"getMatchingMessages",
"(",
"final",
"short",
"id",
",",
"boolean",
"remove",
")",
"{",
"return",
"map",
"(",
"(",
"msg",
",",
"batch",
")",
"->",
"{",
"if",
"(",
"msg",
"!=",
"null",
"&&",
"msg",
".",
"ge... | Removes and returns all messages which have a header with ID == id | [
"Removes",
"and",
"returns",
"all",
"messages",
"which",
"have",
"a",
"header",
"with",
"ID",
"==",
"id"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/MessageBatch.java#L285-L294 | train |
belaban/JGroups | src/org/jgroups/util/MessageBatch.java | MessageBatch.map | public <T> Collection<T> map(BiFunction<Message,MessageBatch,T> visitor) {
Collection<T> retval=null;
for(int i=0; i < index; i++) {
try {
T result=visitor.apply(messages[i], this);
if(result != null) {
if(retval == null)
retval=new ArrayList<>();
retval.add(result);
}
}
catch(Throwable t) {
}
}
return retval;
} | java | public <T> Collection<T> map(BiFunction<Message,MessageBatch,T> visitor) {
Collection<T> retval=null;
for(int i=0; i < index; i++) {
try {
T result=visitor.apply(messages[i], this);
if(result != null) {
if(retval == null)
retval=new ArrayList<>();
retval.add(result);
}
}
catch(Throwable t) {
}
}
return retval;
} | [
"public",
"<",
"T",
">",
"Collection",
"<",
"T",
">",
"map",
"(",
"BiFunction",
"<",
"Message",
",",
"MessageBatch",
",",
"T",
">",
"visitor",
")",
"{",
"Collection",
"<",
"T",
">",
"retval",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";... | Applies a function to all messages and returns a list of the function results | [
"Applies",
"a",
"function",
"to",
"all",
"messages",
"and",
"returns",
"a",
"list",
"of",
"the",
"function",
"results"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/MessageBatch.java#L298-L313 | train |
belaban/JGroups | src/org/jgroups/util/MessageBatch.java | MessageBatch.size | public int size() {
int retval=0;
for(int i=0; i < index; i++)
if(messages[i] != null)
retval++;
return retval;
} | java | public int size() {
int retval=0;
for(int i=0; i < index; i++)
if(messages[i] != null)
retval++;
return retval;
} | [
"public",
"int",
"size",
"(",
")",
"{",
"int",
"retval",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"index",
";",
"i",
"++",
")",
"if",
"(",
"messages",
"[",
"i",
"]",
"!=",
"null",
")",
"retval",
"++",
";",
"return",
"... | Returns the number of non-null messages | [
"Returns",
"the",
"number",
"of",
"non",
"-",
"null",
"messages"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/MessageBatch.java#L327-L333 | train |
belaban/JGroups | src/org/jgroups/protocols/DISCARD.java | DISCARD.shouldDropUpMessage | protected boolean shouldDropUpMessage(@SuppressWarnings("UnusedParameters") Message msg, Address sender) {
if(discard_all && !sender.equals(localAddress()))
return true;
if(ignoredMembers.contains(sender)) {
if(log.isTraceEnabled())
log.trace(localAddress + ": dropping message from " + sender);
num_up++;
return true;
}
if(up > 0) {
double r=Math.random();
if(r < up) {
if(excludeItself && sender.equals(localAddress())) {
if(log.isTraceEnabled())
log.trace("excluding myself");
}
else {
if(log.isTraceEnabled())
log.trace(localAddress + ": dropping message from " + sender);
num_up++;
return true;
}
}
}
return false;
} | java | protected boolean shouldDropUpMessage(@SuppressWarnings("UnusedParameters") Message msg, Address sender) {
if(discard_all && !sender.equals(localAddress()))
return true;
if(ignoredMembers.contains(sender)) {
if(log.isTraceEnabled())
log.trace(localAddress + ": dropping message from " + sender);
num_up++;
return true;
}
if(up > 0) {
double r=Math.random();
if(r < up) {
if(excludeItself && sender.equals(localAddress())) {
if(log.isTraceEnabled())
log.trace("excluding myself");
}
else {
if(log.isTraceEnabled())
log.trace(localAddress + ": dropping message from " + sender);
num_up++;
return true;
}
}
}
return false;
} | [
"protected",
"boolean",
"shouldDropUpMessage",
"(",
"@",
"SuppressWarnings",
"(",
"\"UnusedParameters\"",
")",
"Message",
"msg",
",",
"Address",
"sender",
")",
"{",
"if",
"(",
"discard_all",
"&&",
"!",
"sender",
".",
"equals",
"(",
"localAddress",
"(",
")",
")... | Checks if a message should be passed up, or not | [
"Checks",
"if",
"a",
"message",
"should",
"be",
"passed",
"up",
"or",
"not"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/DISCARD.java#L271-L298 | train |
belaban/JGroups | src/org/jgroups/protocols/TransferQueueBundler.java | TransferQueueBundler.drain | protected void drain() {
Message msg;
while((msg=queue.poll()) != null)
addAndSendIfSizeExceeded(msg);
_sendBundledMessages();
} | java | protected void drain() {
Message msg;
while((msg=queue.poll()) != null)
addAndSendIfSizeExceeded(msg);
_sendBundledMessages();
} | [
"protected",
"void",
"drain",
"(",
")",
"{",
"Message",
"msg",
";",
"while",
"(",
"(",
"msg",
"=",
"queue",
".",
"poll",
"(",
")",
")",
"!=",
"null",
")",
"addAndSendIfSizeExceeded",
"(",
"msg",
")",
";",
"_sendBundledMessages",
"(",
")",
";",
"}"
] | Takes all messages from the queue, adds them to the hashmap and then sends all bundled messages | [
"Takes",
"all",
"messages",
"from",
"the",
"queue",
"adds",
"them",
"to",
"the",
"hashmap",
"and",
"then",
"sends",
"all",
"bundled",
"messages"
] | bd3ca786aa57fed41dfbc10a94b1281e388be03b | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/protocols/TransferQueueBundler.java#L141-L146 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/builder/AbstractTextFieldBuilder.java | AbstractTextFieldBuilder.buildTextComponent | public E buildTextComponent() {
final E textComponent = createTextComponent();
textComponent.setRequired(required);
textComponent.setImmediate(immediate);
textComponent.setReadOnly(readOnly);
textComponent.setEnabled(enabled);
if (!StringUtils.isEmpty(caption)) {
textComponent.setCaption(caption);
}
if (!StringUtils.isEmpty(style)) {
textComponent.setStyleName(style);
}
if (!StringUtils.isEmpty(styleName)) {
textComponent.addStyleName(styleName);
}
if (!StringUtils.isEmpty(prompt)) {
textComponent.setInputPrompt(prompt);
}
if (maxLengthAllowed > 0) {
textComponent.setMaxLength(maxLengthAllowed);
}
if (!StringUtils.isEmpty(id)) {
textComponent.setId(id);
}
if (!validators.isEmpty()) {
validators.forEach(textComponent::addValidator);
}
textComponent.setNullRepresentation("");
return textComponent;
} | java | public E buildTextComponent() {
final E textComponent = createTextComponent();
textComponent.setRequired(required);
textComponent.setImmediate(immediate);
textComponent.setReadOnly(readOnly);
textComponent.setEnabled(enabled);
if (!StringUtils.isEmpty(caption)) {
textComponent.setCaption(caption);
}
if (!StringUtils.isEmpty(style)) {
textComponent.setStyleName(style);
}
if (!StringUtils.isEmpty(styleName)) {
textComponent.addStyleName(styleName);
}
if (!StringUtils.isEmpty(prompt)) {
textComponent.setInputPrompt(prompt);
}
if (maxLengthAllowed > 0) {
textComponent.setMaxLength(maxLengthAllowed);
}
if (!StringUtils.isEmpty(id)) {
textComponent.setId(id);
}
if (!validators.isEmpty()) {
validators.forEach(textComponent::addValidator);
}
textComponent.setNullRepresentation("");
return textComponent;
} | [
"public",
"E",
"buildTextComponent",
"(",
")",
"{",
"final",
"E",
"textComponent",
"=",
"createTextComponent",
"(",
")",
";",
"textComponent",
".",
"setRequired",
"(",
"required",
")",
";",
"textComponent",
".",
"setImmediate",
"(",
"immediate",
")",
";",
"tex... | Build a textfield
@return textfield | [
"Build",
"a",
"textfield"
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/builder/AbstractTextFieldBuilder.java#L160-L198 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/TargetFilterQueryDetailsTable.java | TargetFilterQueryDetailsTable.populateTableByDistributionSet | public void populateTableByDistributionSet(final DistributionSet distributionSet) {
removeAllItems();
if (distributionSet == null) {
return;
}
final Container dataSource = getContainerDataSource();
final List<TargetFilterQuery> filters = distributionSet.getAutoAssignFilters();
filters.forEach(query -> {
final Object itemId = dataSource.addItem();
final Item item = dataSource.getItem(itemId);
item.getItemProperty(TFQ_NAME).setValue(query.getName());
item.getItemProperty(TFQ_QUERY).setValue(query.getQuery());
});
} | java | public void populateTableByDistributionSet(final DistributionSet distributionSet) {
removeAllItems();
if (distributionSet == null) {
return;
}
final Container dataSource = getContainerDataSource();
final List<TargetFilterQuery> filters = distributionSet.getAutoAssignFilters();
filters.forEach(query -> {
final Object itemId = dataSource.addItem();
final Item item = dataSource.getItem(itemId);
item.getItemProperty(TFQ_NAME).setValue(query.getName());
item.getItemProperty(TFQ_QUERY).setValue(query.getQuery());
});
} | [
"public",
"void",
"populateTableByDistributionSet",
"(",
"final",
"DistributionSet",
"distributionSet",
")",
"{",
"removeAllItems",
"(",
")",
";",
"if",
"(",
"distributionSet",
"==",
"null",
")",
"{",
"return",
";",
"}",
"final",
"Container",
"dataSource",
"=",
... | Populate software module metadata.
@param distributionSet
the selected distribution set | [
"Populate",
"software",
"module",
"metadata",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/TargetFilterQueryDetailsTable.java#L48-L63 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java | DistributionAddUpdateWindowLayout.createRequiredComponents | private void createRequiredComponents() {
distNameTextField = createTextField("textfield.name", UIComponentIdProvider.DIST_ADD_NAME,
DistributionSet.NAME_MAX_SIZE);
distVersionTextField = createTextField("textfield.version", UIComponentIdProvider.DIST_ADD_VERSION,
DistributionSet.VERSION_MAX_SIZE);
distsetTypeNameComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("label.combobox.type"), "", null,
"", false, "", i18n.getMessage("label.combobox.type"));
distsetTypeNameComboBox.setImmediate(true);
distsetTypeNameComboBox.setNullSelectionAllowed(false);
distsetTypeNameComboBox.setId(UIComponentIdProvider.DIST_ADD_DISTSETTYPE);
descTextArea = new TextAreaBuilder(DistributionSet.DESCRIPTION_MAX_SIZE)
.caption(i18n.getMessage("textfield.description")).style("text-area-style")
.id(UIComponentIdProvider.DIST_ADD_DESC).buildTextComponent();
reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(i18n.getMessage("checkbox.dist.required.migration.step"),
"dist-checkbox-style", null, false, "");
reqMigStepCheckbox.addStyleName(ValoTheme.CHECKBOX_SMALL);
reqMigStepCheckbox.setId(UIComponentIdProvider.DIST_ADD_MIGRATION_CHECK);
} | java | private void createRequiredComponents() {
distNameTextField = createTextField("textfield.name", UIComponentIdProvider.DIST_ADD_NAME,
DistributionSet.NAME_MAX_SIZE);
distVersionTextField = createTextField("textfield.version", UIComponentIdProvider.DIST_ADD_VERSION,
DistributionSet.VERSION_MAX_SIZE);
distsetTypeNameComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("label.combobox.type"), "", null,
"", false, "", i18n.getMessage("label.combobox.type"));
distsetTypeNameComboBox.setImmediate(true);
distsetTypeNameComboBox.setNullSelectionAllowed(false);
distsetTypeNameComboBox.setId(UIComponentIdProvider.DIST_ADD_DISTSETTYPE);
descTextArea = new TextAreaBuilder(DistributionSet.DESCRIPTION_MAX_SIZE)
.caption(i18n.getMessage("textfield.description")).style("text-area-style")
.id(UIComponentIdProvider.DIST_ADD_DESC).buildTextComponent();
reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(i18n.getMessage("checkbox.dist.required.migration.step"),
"dist-checkbox-style", null, false, "");
reqMigStepCheckbox.addStyleName(ValoTheme.CHECKBOX_SMALL);
reqMigStepCheckbox.setId(UIComponentIdProvider.DIST_ADD_MIGRATION_CHECK);
} | [
"private",
"void",
"createRequiredComponents",
"(",
")",
"{",
"distNameTextField",
"=",
"createTextField",
"(",
"\"textfield.name\"",
",",
"UIComponentIdProvider",
".",
"DIST_ADD_NAME",
",",
"DistributionSet",
".",
"NAME_MAX_SIZE",
")",
";",
"distVersionTextField",
"=",
... | Create required UI components. | [
"Create",
"required",
"UI",
"components",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java#L223-L243 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java | DistributionAddUpdateWindowLayout.getDistSetTypeLazyQueryContainer | private static LazyQueryContainer getDistSetTypeLazyQueryContainer() {
final BeanQueryFactory<DistributionSetTypeBeanQuery> dtQF = new BeanQueryFactory<>(
DistributionSetTypeBeanQuery.class);
dtQF.setQueryConfiguration(Collections.emptyMap());
final LazyQueryContainer disttypeContainer = new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.DIST_TYPE_SIZE, SPUILabelDefinitions.VAR_ID), dtQF);
disttypeContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", true, true);
return disttypeContainer;
} | java | private static LazyQueryContainer getDistSetTypeLazyQueryContainer() {
final BeanQueryFactory<DistributionSetTypeBeanQuery> dtQF = new BeanQueryFactory<>(
DistributionSetTypeBeanQuery.class);
dtQF.setQueryConfiguration(Collections.emptyMap());
final LazyQueryContainer disttypeContainer = new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.DIST_TYPE_SIZE, SPUILabelDefinitions.VAR_ID), dtQF);
disttypeContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", true, true);
return disttypeContainer;
} | [
"private",
"static",
"LazyQueryContainer",
"getDistSetTypeLazyQueryContainer",
"(",
")",
"{",
"final",
"BeanQueryFactory",
"<",
"DistributionSetTypeBeanQuery",
">",
"dtQF",
"=",
"new",
"BeanQueryFactory",
"<>",
"(",
"DistributionSetTypeBeanQuery",
".",
"class",
")",
";",
... | Get the LazyQueryContainer instance for DistributionSetTypes.
@return | [
"Get",
"the",
"LazyQueryContainer",
"instance",
"for",
"DistributionSetTypes",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java#L255-L266 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java | DistributionAddUpdateWindowLayout.resetComponents | public void resetComponents() {
distNameTextField.clear();
distNameTextField.removeStyleName("v-textfield-error");
distVersionTextField.clear();
distVersionTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT);
distsetTypeNameComboBox.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT);
distsetTypeNameComboBox.clear();
distsetTypeNameComboBox.setEnabled(true);
descTextArea.clear();
reqMigStepCheckbox.clear();
} | java | public void resetComponents() {
distNameTextField.clear();
distNameTextField.removeStyleName("v-textfield-error");
distVersionTextField.clear();
distVersionTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT);
distsetTypeNameComboBox.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT);
distsetTypeNameComboBox.clear();
distsetTypeNameComboBox.setEnabled(true);
descTextArea.clear();
reqMigStepCheckbox.clear();
} | [
"public",
"void",
"resetComponents",
"(",
")",
"{",
"distNameTextField",
".",
"clear",
"(",
")",
";",
"distNameTextField",
".",
"removeStyleName",
"(",
"\"v-textfield-error\"",
")",
";",
"distVersionTextField",
".",
"clear",
"(",
")",
";",
"distVersionTextField",
... | clear all the fields. | [
"clear",
"all",
"the",
"fields",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java#L276-L286 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java | DistributionAddUpdateWindowLayout.getWindow | private CommonDialogWindow getWindow(final Long editDistId) {
final SaveDialogCloseListener saveDialogCloseListener;
String caption;
resetComponents();
populateDistSetTypeNameCombo();
if (editDistId == null) {
saveDialogCloseListener = new CreateOnCloseDialogListener();
caption = i18n.getMessage("caption.create.new", i18n.getMessage("caption.distribution"));
} else {
saveDialogCloseListener = new UpdateOnCloseDialogListener(editDistId);
caption = i18n.getMessage("caption.update", i18n.getMessage("caption.distribution"));
populateValuesOfDistribution(editDistId);
}
return new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(caption).content(this).layout(formLayout)
.i18n(i18n).saveDialogCloseListener(saveDialogCloseListener).buildCommonDialogWindow();
} | java | private CommonDialogWindow getWindow(final Long editDistId) {
final SaveDialogCloseListener saveDialogCloseListener;
String caption;
resetComponents();
populateDistSetTypeNameCombo();
if (editDistId == null) {
saveDialogCloseListener = new CreateOnCloseDialogListener();
caption = i18n.getMessage("caption.create.new", i18n.getMessage("caption.distribution"));
} else {
saveDialogCloseListener = new UpdateOnCloseDialogListener(editDistId);
caption = i18n.getMessage("caption.update", i18n.getMessage("caption.distribution"));
populateValuesOfDistribution(editDistId);
}
return new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(caption).content(this).layout(formLayout)
.i18n(i18n).saveDialogCloseListener(saveDialogCloseListener).buildCommonDialogWindow();
} | [
"private",
"CommonDialogWindow",
"getWindow",
"(",
"final",
"Long",
"editDistId",
")",
"{",
"final",
"SaveDialogCloseListener",
"saveDialogCloseListener",
";",
"String",
"caption",
";",
"resetComponents",
"(",
")",
";",
"populateDistSetTypeNameCombo",
"(",
")",
";",
"... | Internal method to create a window to create or update a DistributionSet.
@param editDistId
if <code>null</code> is provided the window is configured to
create a DistributionSet otherwise it is configured for
update.
@return | [
"Internal",
"method",
"to",
"create",
"a",
"window",
"to",
"create",
"or",
"update",
"a",
"DistributionSet",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java#L336-L356 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java | DistributionAddUpdateWindowLayout.populateDistSetTypeNameCombo | private void populateDistSetTypeNameCombo() {
distsetTypeNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer());
distsetTypeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getId());
} | java | private void populateDistSetTypeNameCombo() {
distsetTypeNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer());
distsetTypeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getId());
} | [
"private",
"void",
"populateDistSetTypeNameCombo",
"(",
")",
"{",
"distsetTypeNameComboBox",
".",
"setContainerDataSource",
"(",
"getDistSetTypeLazyQueryContainer",
"(",
")",
")",
";",
"distsetTypeNameComboBox",
".",
"setItemCaptionPropertyId",
"(",
"SPUILabelDefinitions",
".... | Populate DistributionSet Type name combo. | [
"Populate",
"DistributionSet",
"Type",
"name",
"combo",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java#L361-L365 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/miscs/MaintenanceWindowLayout.java | MaintenanceWindowLayout.createMaintenanceScheduleControl | private void createMaintenanceScheduleControl() {
schedule = new TextFieldBuilder(Action.MAINTENANCE_WINDOW_SCHEDULE_LENGTH)
.id(UIComponentIdProvider.MAINTENANCE_WINDOW_SCHEDULE_ID)
.caption(i18n.getMessage("caption.maintenancewindow.schedule")).validator(new CronValidator())
.prompt("0 0 3 ? * 6").required(true, i18n).buildTextComponent();
schedule.addTextChangeListener(new CronTranslationListener());
} | java | private void createMaintenanceScheduleControl() {
schedule = new TextFieldBuilder(Action.MAINTENANCE_WINDOW_SCHEDULE_LENGTH)
.id(UIComponentIdProvider.MAINTENANCE_WINDOW_SCHEDULE_ID)
.caption(i18n.getMessage("caption.maintenancewindow.schedule")).validator(new CronValidator())
.prompt("0 0 3 ? * 6").required(true, i18n).buildTextComponent();
schedule.addTextChangeListener(new CronTranslationListener());
} | [
"private",
"void",
"createMaintenanceScheduleControl",
"(",
")",
"{",
"schedule",
"=",
"new",
"TextFieldBuilder",
"(",
"Action",
".",
"MAINTENANCE_WINDOW_SCHEDULE_LENGTH",
")",
".",
"id",
"(",
"UIComponentIdProvider",
".",
"MAINTENANCE_WINDOW_SCHEDULE_ID",
")",
".",
"ca... | Text field to specify the schedule. | [
"Text",
"field",
"to",
"specify",
"the",
"schedule",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/miscs/MaintenanceWindowLayout.java#L86-L92 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/miscs/MaintenanceWindowLayout.java | MaintenanceWindowLayout.createMaintenanceDurationControl | private void createMaintenanceDurationControl() {
duration = new TextFieldBuilder(Action.MAINTENANCE_WINDOW_DURATION_LENGTH)
.id(UIComponentIdProvider.MAINTENANCE_WINDOW_DURATION_ID)
.caption(i18n.getMessage("caption.maintenancewindow.duration")).validator(new DurationValidator())
.prompt("hh:mm:ss").required(true, i18n).buildTextComponent();
} | java | private void createMaintenanceDurationControl() {
duration = new TextFieldBuilder(Action.MAINTENANCE_WINDOW_DURATION_LENGTH)
.id(UIComponentIdProvider.MAINTENANCE_WINDOW_DURATION_ID)
.caption(i18n.getMessage("caption.maintenancewindow.duration")).validator(new DurationValidator())
.prompt("hh:mm:ss").required(true, i18n).buildTextComponent();
} | [
"private",
"void",
"createMaintenanceDurationControl",
"(",
")",
"{",
"duration",
"=",
"new",
"TextFieldBuilder",
"(",
"Action",
".",
"MAINTENANCE_WINDOW_DURATION_LENGTH",
")",
".",
"id",
"(",
"UIComponentIdProvider",
".",
"MAINTENANCE_WINDOW_DURATION_ID",
")",
".",
"ca... | Text field to specify the duration. | [
"Text",
"field",
"to",
"specify",
"the",
"duration",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/miscs/MaintenanceWindowLayout.java#L152-L157 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/miscs/MaintenanceWindowLayout.java | MaintenanceWindowLayout.createMaintenanceTimeZoneControl | private void createMaintenanceTimeZoneControl() {
// ComboBoxBuilder cannot be used here, because Builder do
// 'comboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);'
// which interferes our code: 'timeZone.addItems(getAllTimeZones());'
timeZone = new ComboBox();
timeZone.setId(UIComponentIdProvider.MAINTENANCE_WINDOW_TIME_ZONE_ID);
timeZone.setCaption(i18n.getMessage("caption.maintenancewindow.timezone"));
timeZone.addItems(getAllTimeZones());
timeZone.setValue(getClientTimeZone());
timeZone.addStyleName(ValoTheme.COMBOBOX_SMALL);
timeZone.setTextInputAllowed(false);
timeZone.setNullSelectionAllowed(false);
} | java | private void createMaintenanceTimeZoneControl() {
// ComboBoxBuilder cannot be used here, because Builder do
// 'comboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);'
// which interferes our code: 'timeZone.addItems(getAllTimeZones());'
timeZone = new ComboBox();
timeZone.setId(UIComponentIdProvider.MAINTENANCE_WINDOW_TIME_ZONE_ID);
timeZone.setCaption(i18n.getMessage("caption.maintenancewindow.timezone"));
timeZone.addItems(getAllTimeZones());
timeZone.setValue(getClientTimeZone());
timeZone.addStyleName(ValoTheme.COMBOBOX_SMALL);
timeZone.setTextInputAllowed(false);
timeZone.setNullSelectionAllowed(false);
} | [
"private",
"void",
"createMaintenanceTimeZoneControl",
"(",
")",
"{",
"// ComboBoxBuilder cannot be used here, because Builder do",
"// 'comboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);'",
"// which interferes our code: 'timeZone.addItems(getAllTimeZones());'",
"timeZone",
"=",
... | Combo box to pick the time zone offset. | [
"Combo",
"box",
"to",
"pick",
"the",
"time",
"zone",
"offset",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/miscs/MaintenanceWindowLayout.java#L185-L197 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/miscs/MaintenanceWindowLayout.java | MaintenanceWindowLayout.getAllTimeZones | private static List<String> getAllTimeZones() {
final List<String> lst = ZoneId.getAvailableZoneIds().stream()
.map(id -> ZonedDateTime.now(ZoneId.of(id)).getOffset().getId().replace("Z", "+00:00")).distinct()
.collect(Collectors.toList());
lst.sort(null);
return lst;
} | java | private static List<String> getAllTimeZones() {
final List<String> lst = ZoneId.getAvailableZoneIds().stream()
.map(id -> ZonedDateTime.now(ZoneId.of(id)).getOffset().getId().replace("Z", "+00:00")).distinct()
.collect(Collectors.toList());
lst.sort(null);
return lst;
} | [
"private",
"static",
"List",
"<",
"String",
">",
"getAllTimeZones",
"(",
")",
"{",
"final",
"List",
"<",
"String",
">",
"lst",
"=",
"ZoneId",
".",
"getAvailableZoneIds",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"id",
"->",
"ZonedDateTime",
"... | Get list of all time zone offsets supported. | [
"Get",
"list",
"of",
"all",
"time",
"zone",
"offsets",
"supported",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/miscs/MaintenanceWindowLayout.java#L202-L208 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/miscs/MaintenanceWindowLayout.java | MaintenanceWindowLayout.getClientTimeZone | private static String getClientTimeZone() {
return ZonedDateTime.now(SPDateTimeUtil.getTimeZoneId(SPDateTimeUtil.getBrowserTimeZone())).getOffset().getId()
.replaceAll("Z", "+00:00");
} | java | private static String getClientTimeZone() {
return ZonedDateTime.now(SPDateTimeUtil.getTimeZoneId(SPDateTimeUtil.getBrowserTimeZone())).getOffset().getId()
.replaceAll("Z", "+00:00");
} | [
"private",
"static",
"String",
"getClientTimeZone",
"(",
")",
"{",
"return",
"ZonedDateTime",
".",
"now",
"(",
"SPDateTimeUtil",
".",
"getTimeZoneId",
"(",
"SPDateTimeUtil",
".",
"getBrowserTimeZone",
"(",
")",
")",
")",
".",
"getOffset",
"(",
")",
".",
"getId... | Get time zone of the browser client to be used as default. | [
"Get",
"time",
"zone",
"of",
"the",
"browser",
"client",
"to",
"be",
"used",
"as",
"default",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/miscs/MaintenanceWindowLayout.java#L213-L216 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/miscs/MaintenanceWindowLayout.java | MaintenanceWindowLayout.createMaintenanceScheduleTranslatorControl | private void createMaintenanceScheduleTranslatorControl() {
scheduleTranslator = new LabelBuilder().id(UIComponentIdProvider.MAINTENANCE_WINDOW_SCHEDULE_TRANSLATOR_ID)
.name(i18n.getMessage(CRON_VALIDATION_ERROR)).buildLabel();
scheduleTranslator.addStyleName(ValoTheme.LABEL_TINY);
} | java | private void createMaintenanceScheduleTranslatorControl() {
scheduleTranslator = new LabelBuilder().id(UIComponentIdProvider.MAINTENANCE_WINDOW_SCHEDULE_TRANSLATOR_ID)
.name(i18n.getMessage(CRON_VALIDATION_ERROR)).buildLabel();
scheduleTranslator.addStyleName(ValoTheme.LABEL_TINY);
} | [
"private",
"void",
"createMaintenanceScheduleTranslatorControl",
"(",
")",
"{",
"scheduleTranslator",
"=",
"new",
"LabelBuilder",
"(",
")",
".",
"id",
"(",
"UIComponentIdProvider",
".",
"MAINTENANCE_WINDOW_SCHEDULE_TRANSLATOR_ID",
")",
".",
"name",
"(",
"i18n",
".",
"... | Label to translate the cron schedule to human readable format. | [
"Label",
"to",
"translate",
"the",
"cron",
"schedule",
"to",
"human",
"readable",
"format",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/miscs/MaintenanceWindowLayout.java#L221-L225 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/miscs/MaintenanceWindowLayout.java | MaintenanceWindowLayout.clearAllControls | public void clearAllControls() {
schedule.setValue("");
duration.setValue("");
timeZone.setValue(getClientTimeZone());
scheduleTranslator.setValue(i18n.getMessage(CRON_VALIDATION_ERROR));
} | java | public void clearAllControls() {
schedule.setValue("");
duration.setValue("");
timeZone.setValue(getClientTimeZone());
scheduleTranslator.setValue(i18n.getMessage(CRON_VALIDATION_ERROR));
} | [
"public",
"void",
"clearAllControls",
"(",
")",
"{",
"schedule",
".",
"setValue",
"(",
"\"\"",
")",
";",
"duration",
".",
"setValue",
"(",
"\"\"",
")",
";",
"timeZone",
".",
"setValue",
"(",
"getClientTimeZone",
"(",
")",
")",
";",
"scheduleTranslator",
".... | Set all the controls to their default values. | [
"Set",
"all",
"the",
"controls",
"to",
"their",
"default",
"values",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/miscs/MaintenanceWindowLayout.java#L258-L263 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/AutoCompleteTextFieldComponent.java | AutoCompleteTextFieldComponent.clear | public void clear() {
queryTextField.clear();
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
validationIcon.setStyleName("hide-status-label");
} | java | public void clear() {
queryTextField.clear();
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
validationIcon.setStyleName("hide-status-label");
} | [
"public",
"void",
"clear",
"(",
")",
"{",
"queryTextField",
".",
"clear",
"(",
")",
";",
"validationIcon",
".",
"setValue",
"(",
"FontAwesome",
".",
"CHECK_CIRCLE",
".",
"getHtml",
"(",
")",
")",
";",
"validationIcon",
".",
"setStyleName",
"(",
"\"hide-statu... | Clears the textfield and resets the validation icon. | [
"Clears",
"the",
"textfield",
"and",
"resets",
"the",
"validation",
"icon",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/AutoCompleteTextFieldComponent.java#L115-L119 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/AutoCompleteTextFieldComponent.java | AutoCompleteTextFieldComponent.showValidationSuccesIcon | public void showValidationSuccesIcon(final String text) {
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON);
filterManagementUIState.setFilterQueryValue(text);
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.FALSE);
} | java | public void showValidationSuccesIcon(final String text) {
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON);
filterManagementUIState.setFilterQueryValue(text);
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.FALSE);
} | [
"public",
"void",
"showValidationSuccesIcon",
"(",
"final",
"String",
"text",
")",
"{",
"validationIcon",
".",
"setValue",
"(",
"FontAwesome",
".",
"CHECK_CIRCLE",
".",
"getHtml",
"(",
")",
")",
";",
"validationIcon",
".",
"setStyleName",
"(",
"SPUIStyleDefinition... | Shows the validation success icon in the textfield
@param text
the text to store in the UI state object | [
"Shows",
"the",
"validation",
"success",
"icon",
"in",
"the",
"textfield"
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/AutoCompleteTextFieldComponent.java#L171-L176 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/AutoCompleteTextFieldComponent.java | AutoCompleteTextFieldComponent.showValidationFailureIcon | public void showValidationFailureIcon(final String validationMessage) {
validationIcon.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
validationIcon.setStyleName(SPUIStyleDefinitions.ERROR_ICON);
validationIcon.setDescription(validationMessage);
filterManagementUIState.setFilterQueryValue(null);
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.TRUE);
} | java | public void showValidationFailureIcon(final String validationMessage) {
validationIcon.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
validationIcon.setStyleName(SPUIStyleDefinitions.ERROR_ICON);
validationIcon.setDescription(validationMessage);
filterManagementUIState.setFilterQueryValue(null);
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.TRUE);
} | [
"public",
"void",
"showValidationFailureIcon",
"(",
"final",
"String",
"validationMessage",
")",
"{",
"validationIcon",
".",
"setValue",
"(",
"FontAwesome",
".",
"TIMES_CIRCLE",
".",
"getHtml",
"(",
")",
")",
";",
"validationIcon",
".",
"setStyleName",
"(",
"SPUIS... | Shows the validation error icon in the textfield
@param validationMessage
the validation message which should be added to the error-icon
tooltip | [
"Shows",
"the",
"validation",
"error",
"icon",
"in",
"the",
"textfield"
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/AutoCompleteTextFieldComponent.java#L185-L191 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/AutoCompleteTextFieldComponent.java | AutoCompleteTextFieldComponent.showValidationInProgress | public void showValidationInProgress() {
validationIcon.setValue(null);
validationIcon.addStyleName("show-status-label");
validationIcon.setStyleName(SPUIStyleDefinitions.TARGET_FILTER_SEARCH_PROGRESS_INDICATOR_STYLE);
} | java | public void showValidationInProgress() {
validationIcon.setValue(null);
validationIcon.addStyleName("show-status-label");
validationIcon.setStyleName(SPUIStyleDefinitions.TARGET_FILTER_SEARCH_PROGRESS_INDICATOR_STYLE);
} | [
"public",
"void",
"showValidationInProgress",
"(",
")",
"{",
"validationIcon",
".",
"setValue",
"(",
"null",
")",
";",
"validationIcon",
".",
"addStyleName",
"(",
"\"show-status-label\"",
")",
";",
"validationIcon",
".",
"setStyleName",
"(",
"SPUIStyleDefinitions",
... | Sets the spinner as progress indicator. | [
"Sets",
"the",
"spinner",
"as",
"progress",
"indicator",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/AutoCompleteTextFieldComponent.java#L239-L243 | train |
eclipse/hawkbit | hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java | SecurityManagedConfiguration.dosSystemFilter | @Bean
@ConditionalOnProperty(prefix = "hawkbit.server.security.dos.filter", name = "enabled", matchIfMissing = true)
public FilterRegistrationBean<DosFilter> dosSystemFilter(final HawkbitSecurityProperties securityProperties) {
final FilterRegistrationBean<DosFilter> filterRegBean = dosFilter(Collections.emptyList(),
securityProperties.getDos().getFilter(), securityProperties.getClients());
filterRegBean.setUrlPatterns(Arrays.asList("/system/*"));
filterRegBean.setOrder(DOS_FILTER_ORDER);
filterRegBean.setName("dosSystemFilter");
return filterRegBean;
} | java | @Bean
@ConditionalOnProperty(prefix = "hawkbit.server.security.dos.filter", name = "enabled", matchIfMissing = true)
public FilterRegistrationBean<DosFilter> dosSystemFilter(final HawkbitSecurityProperties securityProperties) {
final FilterRegistrationBean<DosFilter> filterRegBean = dosFilter(Collections.emptyList(),
securityProperties.getDos().getFilter(), securityProperties.getClients());
filterRegBean.setUrlPatterns(Arrays.asList("/system/*"));
filterRegBean.setOrder(DOS_FILTER_ORDER);
filterRegBean.setName("dosSystemFilter");
return filterRegBean;
} | [
"@",
"Bean",
"@",
"ConditionalOnProperty",
"(",
"prefix",
"=",
"\"hawkbit.server.security.dos.filter\"",
",",
"name",
"=",
"\"enabled\"",
",",
"matchIfMissing",
"=",
"true",
")",
"public",
"FilterRegistrationBean",
"<",
"DosFilter",
">",
"dosSystemFilter",
"(",
"final... | Filter to protect the hawkBit server system management interface against
to many requests.
@param securityProperties
for filter configuration
@return the spring filter registration bean for registering a denial of
service protection filter in the filter chain | [
"Filter",
"to",
"protect",
"the",
"hawkBit",
"server",
"system",
"management",
"interface",
"against",
"to",
"many",
"requests",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java#L385-L396 | train |
eclipse/hawkbit | hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/PropertyMapper.java | PropertyMapper.addNewMapping | public static void addNewMapping(final Class<?> type, final String property, final String mapping) {
allowedColmns.computeIfAbsent(type, k -> new HashMap<>());
allowedColmns.get(type).put(property, mapping);
} | java | public static void addNewMapping(final Class<?> type, final String property, final String mapping) {
allowedColmns.computeIfAbsent(type, k -> new HashMap<>());
allowedColmns.get(type).put(property, mapping);
} | [
"public",
"static",
"void",
"addNewMapping",
"(",
"final",
"Class",
"<",
"?",
">",
"type",
",",
"final",
"String",
"property",
",",
"final",
"String",
"mapping",
")",
"{",
"allowedColmns",
".",
"computeIfAbsent",
"(",
"type",
",",
"k",
"->",
"new",
"HashMa... | Add new mapping - property name and alias.
@param type
entity type
@param property
alias of property
@param mapping
property name | [
"Add",
"new",
"mapping",
"-",
"property",
"name",
"and",
"alias",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/PropertyMapper.java#L38-L41 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadState.java | ArtifactUploadState.clearUploadTempData | public void clearUploadTempData() {
LOG.debug("Cleaning up temp data...");
// delete file system zombies
for (final FileUploadProgress fileUploadProgress : getAllFileUploadProgressValuesFromOverallUploadProcessList()) {
if (!StringUtils.isBlank(fileUploadProgress.getFilePath())) {
final boolean deleted = FileUtils.deleteQuietly(new File(fileUploadProgress.getFilePath()));
if (!deleted) {
LOG.warn("TempFile was not deleted: {}", fileUploadProgress.getFilePath());
}
}
}
clearFileStates();
} | java | public void clearUploadTempData() {
LOG.debug("Cleaning up temp data...");
// delete file system zombies
for (final FileUploadProgress fileUploadProgress : getAllFileUploadProgressValuesFromOverallUploadProcessList()) {
if (!StringUtils.isBlank(fileUploadProgress.getFilePath())) {
final boolean deleted = FileUtils.deleteQuietly(new File(fileUploadProgress.getFilePath()));
if (!deleted) {
LOG.warn("TempFile was not deleted: {}", fileUploadProgress.getFilePath());
}
}
}
clearFileStates();
} | [
"public",
"void",
"clearUploadTempData",
"(",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Cleaning up temp data...\"",
")",
";",
"// delete file system zombies",
"for",
"(",
"final",
"FileUploadProgress",
"fileUploadProgress",
":",
"getAllFileUploadProgressValuesFromOverallUploadP... | Clears all temp data collected while uploading files. | [
"Clears",
"all",
"temp",
"data",
"collected",
"while",
"uploading",
"files",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadState.java#L233-L245 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadState.java | ArtifactUploadState.isUploadInProgressForSelectedSoftwareModule | public boolean isUploadInProgressForSelectedSoftwareModule(final Long softwareModuleId) {
for (final FileUploadId fileUploadId : getAllFileUploadIdsFromOverallUploadProcessList()) {
if (fileUploadId.getSoftwareModuleId().equals(softwareModuleId)) {
return true;
}
}
return false;
} | java | public boolean isUploadInProgressForSelectedSoftwareModule(final Long softwareModuleId) {
for (final FileUploadId fileUploadId : getAllFileUploadIdsFromOverallUploadProcessList()) {
if (fileUploadId.getSoftwareModuleId().equals(softwareModuleId)) {
return true;
}
}
return false;
} | [
"public",
"boolean",
"isUploadInProgressForSelectedSoftwareModule",
"(",
"final",
"Long",
"softwareModuleId",
")",
"{",
"for",
"(",
"final",
"FileUploadId",
"fileUploadId",
":",
"getAllFileUploadIdsFromOverallUploadProcessList",
"(",
")",
")",
"{",
"if",
"(",
"fileUploadI... | Checks if an upload is in progress for the given Software Module
@param softwareModuleId
id of the software module
@return boolean | [
"Checks",
"if",
"an",
"upload",
"is",
"in",
"progress",
"for",
"the",
"given",
"Software",
"Module"
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadState.java#L254-L261 | train |
eclipse/hawkbit | hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/SortUtility.java | SortUtility.getAttributeIdentifierByName | private static <T extends Enum<T> & FieldNameProvider> T getAttributeIdentifierByName(final Class<T> enumType,
final String name) {
try {
return Enum.valueOf(enumType, name.toUpperCase());
} catch (final IllegalArgumentException e) {
throw new SortParameterUnsupportedFieldException(e);
}
} | java | private static <T extends Enum<T> & FieldNameProvider> T getAttributeIdentifierByName(final Class<T> enumType,
final String name) {
try {
return Enum.valueOf(enumType, name.toUpperCase());
} catch (final IllegalArgumentException e) {
throw new SortParameterUnsupportedFieldException(e);
}
} | [
"private",
"static",
"<",
"T",
"extends",
"Enum",
"<",
"T",
">",
"&",
"FieldNameProvider",
">",
"T",
"getAttributeIdentifierByName",
"(",
"final",
"Class",
"<",
"T",
">",
"enumType",
",",
"final",
"String",
"name",
")",
"{",
"try",
"{",
"return",
"Enum",
... | Returns the attribute identifier for the given name.
@param enumType
the class of the enum which the fields in the sort string
should be related to.
@param name
the name of the enum
@param <T>
the type of the enumeration which must be derived from
{@link FieldNameProvider}
@return the corresponding enum
@throws SortParameterUnsupportedFieldException
if there is no matching enum for the specified name | [
"Returns",
"the",
"attribute",
"identifier",
"for",
"the",
"given",
"name",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/SortUtility.java#L110-L117 | train |
eclipse/hawkbit | hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java | AmqpMessageDispatcherService.targetCancelAssignmentToDistributionSet | @EventListener(classes = CancelTargetAssignmentEvent.class)
protected void targetCancelAssignmentToDistributionSet(final CancelTargetAssignmentEvent cancelEvent) {
if (isNotFromSelf(cancelEvent)) {
return;
}
sendCancelMessageToTarget(cancelEvent.getTenant(), cancelEvent.getEntity().getControllerId(),
cancelEvent.getActionId(), cancelEvent.getEntity().getAddress());
} | java | @EventListener(classes = CancelTargetAssignmentEvent.class)
protected void targetCancelAssignmentToDistributionSet(final CancelTargetAssignmentEvent cancelEvent) {
if (isNotFromSelf(cancelEvent)) {
return;
}
sendCancelMessageToTarget(cancelEvent.getTenant(), cancelEvent.getEntity().getControllerId(),
cancelEvent.getActionId(), cancelEvent.getEntity().getAddress());
} | [
"@",
"EventListener",
"(",
"classes",
"=",
"CancelTargetAssignmentEvent",
".",
"class",
")",
"protected",
"void",
"targetCancelAssignmentToDistributionSet",
"(",
"final",
"CancelTargetAssignmentEvent",
"cancelEvent",
")",
"{",
"if",
"(",
"isNotFromSelf",
"(",
"cancelEvent... | Method to send a message to a RabbitMQ Exchange after the assignment of
the Distribution set to a Target has been canceled.
@param cancelEvent
the object to be send. | [
"Method",
"to",
"send",
"a",
"message",
"to",
"a",
"RabbitMQ",
"Exchange",
"after",
"the",
"assignment",
"of",
"the",
"Distribution",
"set",
"to",
"a",
"Target",
"has",
"been",
"canceled",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java#L179-L187 | train |
eclipse/hawkbit | hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java | AmqpMessageDispatcherService.targetDelete | @EventListener(classes = TargetDeletedEvent.class)
protected void targetDelete(final TargetDeletedEvent deleteEvent) {
if (isNotFromSelf(deleteEvent)) {
return;
}
sendDeleteMessage(deleteEvent.getTenant(), deleteEvent.getControllerId(), deleteEvent.getTargetAddress());
} | java | @EventListener(classes = TargetDeletedEvent.class)
protected void targetDelete(final TargetDeletedEvent deleteEvent) {
if (isNotFromSelf(deleteEvent)) {
return;
}
sendDeleteMessage(deleteEvent.getTenant(), deleteEvent.getControllerId(), deleteEvent.getTargetAddress());
} | [
"@",
"EventListener",
"(",
"classes",
"=",
"TargetDeletedEvent",
".",
"class",
")",
"protected",
"void",
"targetDelete",
"(",
"final",
"TargetDeletedEvent",
"deleteEvent",
")",
"{",
"if",
"(",
"isNotFromSelf",
"(",
"deleteEvent",
")",
")",
"{",
"return",
";",
... | Method to send a message to a RabbitMQ Exchange after a Target was
deleted.
@param deleteEvent
the TargetDeletedEvent which holds the necessary data for
sending a target delete message. | [
"Method",
"to",
"send",
"a",
"message",
"to",
"a",
"RabbitMQ",
"Exchange",
"after",
"a",
"Target",
"was",
"deleted",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java#L197-L203 | train |
eclipse/hawkbit | hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/system/MgmtSystemTenantConfigurationValueRequest.java | MgmtSystemTenantConfigurationValueRequest.setValue | public void setValue(final Object value) {
if (!(value instanceof Serializable)) {
throw new IllegalArgumentException("The value muste be a instance of " + Serializable.class.getName());
}
this.value = (Serializable) value;
} | java | public void setValue(final Object value) {
if (!(value instanceof Serializable)) {
throw new IllegalArgumentException("The value muste be a instance of " + Serializable.class.getName());
}
this.value = (Serializable) value;
} | [
"public",
"void",
"setValue",
"(",
"final",
"Object",
"value",
")",
"{",
"if",
"(",
"!",
"(",
"value",
"instanceof",
"Serializable",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The value muste be a instance of \"",
"+",
"Serializable",
".",
... | Sets the MgmtSystemTenantConfigurationValueRequest
@param value | [
"Sets",
"the",
"MgmtSystemTenantConfigurationValueRequest"
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/system/MgmtSystemTenantConfigurationValueRequest.java#L41-L46 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleMetadataDetailsLayout.java | SoftwareModuleMetadataDetailsLayout.populateSMMetadata | public void populateSMMetadata(final SoftwareModule swModule) {
removeAllItems();
if (null == swModule) {
return;
}
selectedSWModuleId = swModule.getId();
final List<SoftwareModuleMetadata> swMetadataList = softwareModuleManagement
.findMetaDataBySoftwareModuleId(PageRequest.of(0, MAX_METADATA_QUERY), selectedSWModuleId).getContent();
if (!CollectionUtils.isEmpty(swMetadataList)) {
swMetadataList.forEach(this::setMetadataProperties);
}
} | java | public void populateSMMetadata(final SoftwareModule swModule) {
removeAllItems();
if (null == swModule) {
return;
}
selectedSWModuleId = swModule.getId();
final List<SoftwareModuleMetadata> swMetadataList = softwareModuleManagement
.findMetaDataBySoftwareModuleId(PageRequest.of(0, MAX_METADATA_QUERY), selectedSWModuleId).getContent();
if (!CollectionUtils.isEmpty(swMetadataList)) {
swMetadataList.forEach(this::setMetadataProperties);
}
} | [
"public",
"void",
"populateSMMetadata",
"(",
"final",
"SoftwareModule",
"swModule",
")",
"{",
"removeAllItems",
"(",
")",
";",
"if",
"(",
"null",
"==",
"swModule",
")",
"{",
"return",
";",
"}",
"selectedSWModuleId",
"=",
"swModule",
".",
"getId",
"(",
")",
... | Populate software module metadata table.
@param swModule | [
"Populate",
"software",
"module",
"metadata",
"table",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleMetadataDetailsLayout.java#L60-L71 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/groupschart/client/GroupsPieChartWidget.java | GroupsPieChartWidget.update | public void update(final List<Long> groupTargetCounts, final Long totalTargetCount) {
this.groupTargetCounts = groupTargetCounts;
this.totalTargetCount = totalTargetCount;
if (groupTargetCounts != null) {
long sum = 0;
for (Long targetCount : groupTargetCounts) {
sum += targetCount;
}
unassignedTargets = totalTargetCount - sum;
}
draw();
} | java | public void update(final List<Long> groupTargetCounts, final Long totalTargetCount) {
this.groupTargetCounts = groupTargetCounts;
this.totalTargetCount = totalTargetCount;
if (groupTargetCounts != null) {
long sum = 0;
for (Long targetCount : groupTargetCounts) {
sum += targetCount;
}
unassignedTargets = totalTargetCount - sum;
}
draw();
} | [
"public",
"void",
"update",
"(",
"final",
"List",
"<",
"Long",
">",
"groupTargetCounts",
",",
"final",
"Long",
"totalTargetCount",
")",
"{",
"this",
".",
"groupTargetCounts",
"=",
"groupTargetCounts",
";",
"this",
".",
"totalTargetCount",
"=",
"totalTargetCount",
... | Updates the pie chart with new data
@param groupTargetCounts
list of target counts
@param totalTargetCount
total count of targets that are represented by the pie | [
"Updates",
"the",
"pie",
"chart",
"with",
"new",
"data"
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/groupschart/client/GroupsPieChartWidget.java#L73-L87 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java | TargetTableHeader.doValidations | private Boolean doValidations(final DragAndDropEvent dragEvent) {
final Component compsource = dragEvent.getTransferable().getSourceComponent();
Boolean isValid = Boolean.TRUE;
if (compsource instanceof Table && !isComplexFilterViewDisplayed) {
final TableTransferable transferable = (TableTransferable) dragEvent.getTransferable();
final Table source = transferable.getSourceComponent();
if (!source.getId().equals(UIComponentIdProvider.DIST_TABLE_ID)) {
notification.displayValidationError(i18n.getMessage(UIMessageIdProvider.MESSAGE_ACTION_NOT_ALLOWED));
isValid = Boolean.FALSE;
} else {
if (getDropppedDistributionDetails(transferable).size() > 1) {
notification.displayValidationError(i18n.getMessage("message.onlyone.distribution.dropallowed"));
isValid = Boolean.FALSE;
}
}
} else {
notification.displayValidationError(i18n.getMessage(UIMessageIdProvider.MESSAGE_ACTION_NOT_ALLOWED));
isValid = Boolean.FALSE;
}
return isValid;
} | java | private Boolean doValidations(final DragAndDropEvent dragEvent) {
final Component compsource = dragEvent.getTransferable().getSourceComponent();
Boolean isValid = Boolean.TRUE;
if (compsource instanceof Table && !isComplexFilterViewDisplayed) {
final TableTransferable transferable = (TableTransferable) dragEvent.getTransferable();
final Table source = transferable.getSourceComponent();
if (!source.getId().equals(UIComponentIdProvider.DIST_TABLE_ID)) {
notification.displayValidationError(i18n.getMessage(UIMessageIdProvider.MESSAGE_ACTION_NOT_ALLOWED));
isValid = Boolean.FALSE;
} else {
if (getDropppedDistributionDetails(transferable).size() > 1) {
notification.displayValidationError(i18n.getMessage("message.onlyone.distribution.dropallowed"));
isValid = Boolean.FALSE;
}
}
} else {
notification.displayValidationError(i18n.getMessage(UIMessageIdProvider.MESSAGE_ACTION_NOT_ALLOWED));
isValid = Boolean.FALSE;
}
return isValid;
} | [
"private",
"Boolean",
"doValidations",
"(",
"final",
"DragAndDropEvent",
"dragEvent",
")",
"{",
"final",
"Component",
"compsource",
"=",
"dragEvent",
".",
"getTransferable",
"(",
")",
".",
"getSourceComponent",
"(",
")",
";",
"Boolean",
"isValid",
"=",
"Boolean",
... | Validation for drag event.
@param dragEvent
@return | [
"Validation",
"for",
"drag",
"event",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java#L356-L377 | train |
eclipse/hawkbit | hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java | MgmtSystemManagementResource.deleteTenant | @Override
public ResponseEntity<Void> deleteTenant(@PathVariable("tenant") final String tenant) {
systemManagement.deleteTenant(tenant);
return ResponseEntity.ok().build();
} | java | @Override
public ResponseEntity<Void> deleteTenant(@PathVariable("tenant") final String tenant) {
systemManagement.deleteTenant(tenant);
return ResponseEntity.ok().build();
} | [
"@",
"Override",
"public",
"ResponseEntity",
"<",
"Void",
">",
"deleteTenant",
"(",
"@",
"PathVariable",
"(",
"\"tenant\"",
")",
"final",
"String",
"tenant",
")",
"{",
"systemManagement",
".",
"deleteTenant",
"(",
"tenant",
")",
";",
"return",
"ResponseEntity",
... | Deletes the tenant data of a given tenant. USE WITH CARE!
@param tenant
to delete
@return HttpStatus.OK | [
"Deletes",
"the",
"tenant",
"data",
"of",
"a",
"given",
"tenant",
".",
"USE",
"WITH",
"CARE!"
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java#L58-L62 | train |
eclipse/hawkbit | hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java | MgmtSystemManagementResource.getSystemUsageStats | @Override
public ResponseEntity<MgmtSystemStatisticsRest> getSystemUsageStats() {
final SystemUsageReportWithTenants report = systemManagement.getSystemUsageStatisticsWithTenants();
final MgmtSystemStatisticsRest result = new MgmtSystemStatisticsRest()
.setOverallActions(report.getOverallActions()).setOverallArtifacts(report.getOverallArtifacts())
.setOverallArtifactVolumeInBytes(report.getOverallArtifactVolumeInBytes())
.setOverallTargets(report.getOverallTargets()).setOverallTenants(report.getTenants().size());
result.setTenantStats(report.getTenants().stream().map(MgmtSystemManagementResource::convertTenant)
.collect(Collectors.toList()));
return ResponseEntity.ok(result);
} | java | @Override
public ResponseEntity<MgmtSystemStatisticsRest> getSystemUsageStats() {
final SystemUsageReportWithTenants report = systemManagement.getSystemUsageStatisticsWithTenants();
final MgmtSystemStatisticsRest result = new MgmtSystemStatisticsRest()
.setOverallActions(report.getOverallActions()).setOverallArtifacts(report.getOverallArtifacts())
.setOverallArtifactVolumeInBytes(report.getOverallArtifactVolumeInBytes())
.setOverallTargets(report.getOverallTargets()).setOverallTenants(report.getTenants().size());
result.setTenantStats(report.getTenants().stream().map(MgmtSystemManagementResource::convertTenant)
.collect(Collectors.toList()));
return ResponseEntity.ok(result);
} | [
"@",
"Override",
"public",
"ResponseEntity",
"<",
"MgmtSystemStatisticsRest",
">",
"getSystemUsageStats",
"(",
")",
"{",
"final",
"SystemUsageReportWithTenants",
"report",
"=",
"systemManagement",
".",
"getSystemUsageStatisticsWithTenants",
"(",
")",
";",
"final",
"MgmtSy... | Collects and returns system usage statistics. It provides a system wide
overview and tenant based stats.
@return system usage statistics | [
"Collects",
"and",
"returns",
"system",
"usage",
"statistics",
".",
"It",
"provides",
"a",
"system",
"wide",
"overview",
"and",
"tenant",
"based",
"stats",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java#L70-L83 | train |
eclipse/hawkbit | hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java | MgmtSystemManagementResource.getCaches | @Override
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
public ResponseEntity<Collection<MgmtSystemCache>> getCaches() {
final Collection<String> cacheNames = cacheManager.getCacheNames();
return ResponseEntity
.ok(cacheNames.stream().map(cacheManager::getCache).map(this::cacheRest).collect(Collectors.toList()));
} | java | @Override
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
public ResponseEntity<Collection<MgmtSystemCache>> getCaches() {
final Collection<String> cacheNames = cacheManager.getCacheNames();
return ResponseEntity
.ok(cacheNames.stream().map(cacheManager::getCache).map(this::cacheRest).collect(Collectors.toList()));
} | [
"@",
"Override",
"@",
"PreAuthorize",
"(",
"SpringEvalExpressions",
".",
"HAS_AUTH_SYSTEM_ADMIN",
")",
"public",
"ResponseEntity",
"<",
"Collection",
"<",
"MgmtSystemCache",
">",
">",
"getCaches",
"(",
")",
"{",
"final",
"Collection",
"<",
"String",
">",
"cacheNam... | Returns a list of all caches.
@return a list of caches for all tenants | [
"Returns",
"a",
"list",
"of",
"all",
"caches",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java#L103-L109 | train |
eclipse/hawkbit | hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java | MgmtSystemManagementResource.invalidateCaches | @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
@Override
public ResponseEntity<Collection<String>> invalidateCaches() {
final Collection<String> cacheNames = cacheManager.getCacheNames();
LOGGER.info("Invalidating caches {}", cacheNames);
cacheNames.forEach(cacheName -> cacheManager.getCache(cacheName).clear());
return ResponseEntity.ok(cacheNames);
} | java | @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
@Override
public ResponseEntity<Collection<String>> invalidateCaches() {
final Collection<String> cacheNames = cacheManager.getCacheNames();
LOGGER.info("Invalidating caches {}", cacheNames);
cacheNames.forEach(cacheName -> cacheManager.getCache(cacheName).clear());
return ResponseEntity.ok(cacheNames);
} | [
"@",
"PreAuthorize",
"(",
"SpringEvalExpressions",
".",
"HAS_AUTH_SYSTEM_ADMIN",
")",
"@",
"Override",
"public",
"ResponseEntity",
"<",
"Collection",
"<",
"String",
">",
">",
"invalidateCaches",
"(",
")",
"{",
"final",
"Collection",
"<",
"String",
">",
"cacheNames... | Invalidates all caches for all tenants.
@return a list of cache names which has been invalidated | [
"Invalidates",
"all",
"caches",
"for",
"all",
"tenants",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java#L116-L123 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/generic/AbstractBooleanTenantConfigurationItem.java | AbstractBooleanTenantConfigurationItem.init | protected void init(final String labelText) {
setImmediate(true);
addComponent(new LabelBuilder().name(i18n.getMessage(labelText)).buildLabel());
} | java | protected void init(final String labelText) {
setImmediate(true);
addComponent(new LabelBuilder().name(i18n.getMessage(labelText)).buildLabel());
} | [
"protected",
"void",
"init",
"(",
"final",
"String",
"labelText",
")",
"{",
"setImmediate",
"(",
"true",
")",
";",
"addComponent",
"(",
"new",
"LabelBuilder",
"(",
")",
".",
"name",
"(",
"i18n",
".",
"getMessage",
"(",
"labelText",
")",
")",
".",
"buildL... | initialize the abstract component. | [
"initialize",
"the",
"abstract",
"component",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/generic/AbstractBooleanTenantConfigurationItem.java#L53-L56 | train |
eclipse/hawkbit | hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java | AmqpDeadletterProperties.getDeadLetterExchangeArgs | public Map<String, Object> getDeadLetterExchangeArgs(final String exchange) {
final Map<String, Object> args = Maps.newHashMapWithExpectedSize(1);
args.put("x-dead-letter-exchange", exchange);
return args;
} | java | public Map<String, Object> getDeadLetterExchangeArgs(final String exchange) {
final Map<String, Object> args = Maps.newHashMapWithExpectedSize(1);
args.put("x-dead-letter-exchange", exchange);
return args;
} | [
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"getDeadLetterExchangeArgs",
"(",
"final",
"String",
"exchange",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"args",
"=",
"Maps",
".",
"newHashMapWithExpectedSize",
"(",
"1",
")",
";",
"a... | Return the deadletter arguments.
@param exchange
the deadletter exchange
@return map which holds the properties | [
"Return",
"the",
"deadletter",
"arguments",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java#L40-L44 | train |
eclipse/hawkbit | hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java | AmqpDeadletterProperties.createDeadletterQueue | public Queue createDeadletterQueue(final String queueName) {
return new Queue(queueName, true, false, false, getTTLArgs());
} | java | public Queue createDeadletterQueue(final String queueName) {
return new Queue(queueName, true, false, false, getTTLArgs());
} | [
"public",
"Queue",
"createDeadletterQueue",
"(",
"final",
"String",
"queueName",
")",
"{",
"return",
"new",
"Queue",
"(",
"queueName",
",",
"true",
",",
"false",
",",
"false",
",",
"getTTLArgs",
"(",
")",
")",
";",
"}"
] | Create a deadletter queue with ttl for messages
@param queueName
the deadlette queue name
@return the deadletter queue | [
"Create",
"a",
"deadletter",
"queue",
"with",
"ttl",
"for",
"messages"
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java#L53-L55 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java | TargetAddUpdateWindowLayout.updateTarget | public void updateTarget() {
/* save updated entity */
final Target target = targetManagement.update(entityFactory.target().update(controllerId)
.name(nameTextField.getValue()).description(descTextArea.getValue()));
/* display success msg */
uINotification.displaySuccess(i18n.getMessage("message.update.success", target.getName()));
// publishing through event bus
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.UPDATED_ENTITY, target));
} | java | public void updateTarget() {
/* save updated entity */
final Target target = targetManagement.update(entityFactory.target().update(controllerId)
.name(nameTextField.getValue()).description(descTextArea.getValue()));
/* display success msg */
uINotification.displaySuccess(i18n.getMessage("message.update.success", target.getName()));
// publishing through event bus
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.UPDATED_ENTITY, target));
} | [
"public",
"void",
"updateTarget",
"(",
")",
"{",
"/* save updated entity */",
"final",
"Target",
"target",
"=",
"targetManagement",
".",
"update",
"(",
"entityFactory",
".",
"target",
"(",
")",
".",
"update",
"(",
"controllerId",
")",
".",
"name",
"(",
"nameTe... | Update the Target if modified. | [
"Update",
"the",
"Target",
"if",
"modified",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java#L128-L136 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java | TargetAddUpdateWindowLayout.getWindow | public Window getWindow(final String controllerId) {
final Optional<Target> target = targetManagement.getByControllerID(controllerId);
if (!target.isPresent()) {
uINotification.displayWarning(i18n.getMessage("target.not.exists", controllerId));
return null;
}
populateValuesOfTarget(target.get());
createNewWindow();
window.setCaption(i18n.getMessage("caption.update", i18n.getMessage("caption.target")));
window.addStyleName("target-update-window");
return window;
} | java | public Window getWindow(final String controllerId) {
final Optional<Target> target = targetManagement.getByControllerID(controllerId);
if (!target.isPresent()) {
uINotification.displayWarning(i18n.getMessage("target.not.exists", controllerId));
return null;
}
populateValuesOfTarget(target.get());
createNewWindow();
window.setCaption(i18n.getMessage("caption.update", i18n.getMessage("caption.target")));
window.addStyleName("target-update-window");
return window;
} | [
"public",
"Window",
"getWindow",
"(",
"final",
"String",
"controllerId",
")",
"{",
"final",
"Optional",
"<",
"Target",
">",
"target",
"=",
"targetManagement",
".",
"getByControllerID",
"(",
"controllerId",
")",
";",
"if",
"(",
"!",
"target",
".",
"isPresent",
... | Returns Target Update window based on the selected Entity Id in the
target table.
@param controllerId
the target controller id
@return window or {@code null} if target is not exists. | [
"Returns",
"Target",
"Update",
"window",
"based",
"on",
"the",
"selected",
"Entity",
"Id",
"in",
"the",
"target",
"table",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java#L167-L178 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java | TargetAddUpdateWindowLayout.resetComponents | public void resetComponents() {
nameTextField.clear();
nameTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
controllerIDTextField.setEnabled(Boolean.TRUE);
controllerIDTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
controllerIDTextField.clear();
descTextArea.clear();
editTarget = Boolean.FALSE;
} | java | public void resetComponents() {
nameTextField.clear();
nameTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
controllerIDTextField.setEnabled(Boolean.TRUE);
controllerIDTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
controllerIDTextField.clear();
descTextArea.clear();
editTarget = Boolean.FALSE;
} | [
"public",
"void",
"resetComponents",
"(",
")",
"{",
"nameTextField",
".",
"clear",
"(",
")",
";",
"nameTextField",
".",
"removeStyleName",
"(",
"SPUIStyleDefinitions",
".",
"SP_TEXTFIELD_ERROR",
")",
";",
"controllerIDTextField",
".",
"setEnabled",
"(",
"Boolean",
... | clear all fields of Target Edit Window. | [
"clear",
"all",
"fields",
"of",
"Target",
"Edit",
"Window",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java#L183-L191 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/colorpicker/ColorPickerHelper.java | ColorPickerHelper.getColorPickedString | public static String getColorPickedString(final SpColorPickerPreview preview) {
final Color color = preview.getColor();
return "rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ")";
} | java | public static String getColorPickedString(final SpColorPickerPreview preview) {
final Color color = preview.getColor();
return "rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ")";
} | [
"public",
"static",
"String",
"getColorPickedString",
"(",
"final",
"SpColorPickerPreview",
"preview",
")",
"{",
"final",
"Color",
"color",
"=",
"preview",
".",
"getColor",
"(",
")",
";",
"return",
"\"rgb(\"",
"+",
"color",
".",
"getRed",
"(",
")",
"+",
"\",... | Get color picked value as string.
@param preview
the color picker preview
@return String of color picked value. | [
"Get",
"color",
"picked",
"value",
"as",
"string",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/colorpicker/ColorPickerHelper.java#L38-L42 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.