id
int32
0
165k
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
15,700
knowm/XChange
xchange-dragonex/src/main/java/org/knowm/xchange/dragonex/service/DragonexBaseService.java
DragonexBaseService.utcNow
protected static String utcNow() { Calendar calendar = Calendar.getInstance(); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); return dateFormat.format(calendar.getTime()); // return java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME.format( // ZonedDateTime.now(ZoneOffset.UTC)); }
java
protected static String utcNow() { Calendar calendar = Calendar.getInstance(); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); return dateFormat.format(calendar.getTime()); // return java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME.format( // ZonedDateTime.now(ZoneOffset.UTC)); }
[ "protected", "static", "String", "utcNow", "(", ")", "{", "Calendar", "calendar", "=", "Calendar", ".", "getInstance", "(", ")", ";", "SimpleDateFormat", "dateFormat", "=", "new", "SimpleDateFormat", "(", "\"EEE, dd MMM yyyy HH:mm:ss z\"", ",", "Locale", ".", "US", ")", ";", "dateFormat", ".", "setTimeZone", "(", "TimeZone", ".", "getTimeZone", "(", "\"GMT\"", ")", ")", ";", "return", "dateFormat", ".", "format", "(", "calendar", ".", "getTime", "(", ")", ")", ";", "// return java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME.format(", "// ZonedDateTime.now(ZoneOffset.UTC));", "}" ]
current date in utc as http header
[ "current", "date", "in", "utc", "as", "http", "header" ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-dragonex/src/main/java/org/knowm/xchange/dragonex/service/DragonexBaseService.java#L21-L29
15,701
knowm/XChange
xchange-huobi/src/main/java/org/knowm/xchange/huobi/HuobiAdapters.java
HuobiAdapters.adaptTicker
public static Ticker adaptTicker(HuobiTicker huobiTicker, CurrencyPair currencyPair) { Ticker.Builder builder = new Ticker.Builder(); builder.open(huobiTicker.getOpen()); builder.ask(huobiTicker.getAsk().getPrice()); builder.bid(huobiTicker.getBid().getPrice()); builder.last(huobiTicker.getClose()); builder.high(huobiTicker.getHigh()); builder.low(huobiTicker.getLow()); builder.volume(huobiTicker.getVol()); builder.timestamp(huobiTicker.getTs()); builder.currencyPair(currencyPair); return builder.build(); }
java
public static Ticker adaptTicker(HuobiTicker huobiTicker, CurrencyPair currencyPair) { Ticker.Builder builder = new Ticker.Builder(); builder.open(huobiTicker.getOpen()); builder.ask(huobiTicker.getAsk().getPrice()); builder.bid(huobiTicker.getBid().getPrice()); builder.last(huobiTicker.getClose()); builder.high(huobiTicker.getHigh()); builder.low(huobiTicker.getLow()); builder.volume(huobiTicker.getVol()); builder.timestamp(huobiTicker.getTs()); builder.currencyPair(currencyPair); return builder.build(); }
[ "public", "static", "Ticker", "adaptTicker", "(", "HuobiTicker", "huobiTicker", ",", "CurrencyPair", "currencyPair", ")", "{", "Ticker", ".", "Builder", "builder", "=", "new", "Ticker", ".", "Builder", "(", ")", ";", "builder", ".", "open", "(", "huobiTicker", ".", "getOpen", "(", ")", ")", ";", "builder", ".", "ask", "(", "huobiTicker", ".", "getAsk", "(", ")", ".", "getPrice", "(", ")", ")", ";", "builder", ".", "bid", "(", "huobiTicker", ".", "getBid", "(", ")", ".", "getPrice", "(", ")", ")", ";", "builder", ".", "last", "(", "huobiTicker", ".", "getClose", "(", ")", ")", ";", "builder", ".", "high", "(", "huobiTicker", ".", "getHigh", "(", ")", ")", ";", "builder", ".", "low", "(", "huobiTicker", ".", "getLow", "(", ")", ")", ";", "builder", ".", "volume", "(", "huobiTicker", ".", "getVol", "(", ")", ")", ";", "builder", ".", "timestamp", "(", "huobiTicker", ".", "getTs", "(", ")", ")", ";", "builder", ".", "currencyPair", "(", "currencyPair", ")", ";", "return", "builder", ".", "build", "(", ")", ";", "}" ]
Trading fee at Huobi is 0.2 %
[ "Trading", "fee", "at", "Huobi", "is", "0", ".", "2", "%" ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-huobi/src/main/java/org/knowm/xchange/huobi/HuobiAdapters.java#L42-L54
15,702
knowm/XChange
xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockAccountServiceRaw.java
TheRockAccountServiceRaw.withdrawDefault
public TheRockWithdrawalResponse withdrawDefault( Currency currency, BigDecimal amount, String destinationAddress) throws TheRockException, IOException { final TheRockWithdrawal withdrawal = TheRockWithdrawal.createDefaultWithdrawal( currency.getCurrencyCode(), amount, destinationAddress); return theRockAuthenticated.withdraw( apiKey, signatureCreator, exchange.getNonceFactory(), withdrawal); }
java
public TheRockWithdrawalResponse withdrawDefault( Currency currency, BigDecimal amount, String destinationAddress) throws TheRockException, IOException { final TheRockWithdrawal withdrawal = TheRockWithdrawal.createDefaultWithdrawal( currency.getCurrencyCode(), amount, destinationAddress); return theRockAuthenticated.withdraw( apiKey, signatureCreator, exchange.getNonceFactory(), withdrawal); }
[ "public", "TheRockWithdrawalResponse", "withdrawDefault", "(", "Currency", "currency", ",", "BigDecimal", "amount", ",", "String", "destinationAddress", ")", "throws", "TheRockException", ",", "IOException", "{", "final", "TheRockWithdrawal", "withdrawal", "=", "TheRockWithdrawal", ".", "createDefaultWithdrawal", "(", "currency", ".", "getCurrencyCode", "(", ")", ",", "amount", ",", "destinationAddress", ")", ";", "return", "theRockAuthenticated", ".", "withdraw", "(", "apiKey", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ",", "withdrawal", ")", ";", "}" ]
Withdraw using the default method
[ "Withdraw", "using", "the", "default", "method" ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockAccountServiceRaw.java#L37-L45
15,703
knowm/XChange
xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockAccountServiceRaw.java
TheRockAccountServiceRaw.withdrawRipple
public TheRockWithdrawalResponse withdrawRipple( Currency currency, BigDecimal amount, String destinationAddress, Long destinationTag) throws TheRockException, IOException { final TheRockWithdrawal withdrawal = TheRockWithdrawal.createRippleWithdrawal( currency.getCurrencyCode(), amount, destinationAddress, destinationTag); return theRockAuthenticated.withdraw( apiKey, signatureCreator, exchange.getNonceFactory(), withdrawal); }
java
public TheRockWithdrawalResponse withdrawRipple( Currency currency, BigDecimal amount, String destinationAddress, Long destinationTag) throws TheRockException, IOException { final TheRockWithdrawal withdrawal = TheRockWithdrawal.createRippleWithdrawal( currency.getCurrencyCode(), amount, destinationAddress, destinationTag); return theRockAuthenticated.withdraw( apiKey, signatureCreator, exchange.getNonceFactory(), withdrawal); }
[ "public", "TheRockWithdrawalResponse", "withdrawRipple", "(", "Currency", "currency", ",", "BigDecimal", "amount", ",", "String", "destinationAddress", ",", "Long", "destinationTag", ")", "throws", "TheRockException", ",", "IOException", "{", "final", "TheRockWithdrawal", "withdrawal", "=", "TheRockWithdrawal", ".", "createRippleWithdrawal", "(", "currency", ".", "getCurrencyCode", "(", ")", ",", "amount", ",", "destinationAddress", ",", "destinationTag", ")", ";", "return", "theRockAuthenticated", ".", "withdraw", "(", "apiKey", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ",", "withdrawal", ")", ";", "}" ]
Withdraw to Ripple
[ "Withdraw", "to", "Ripple" ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockAccountServiceRaw.java#L48-L56
15,704
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/v2/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.getCoinbaseAccounts
public List<CoinbaseAccount> getCoinbaseAccounts() throws IOException { String apiKey = exchange.getExchangeSpecification().getApiKey(); BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch(); return coinbase .getAccounts(Coinbase.CB_VERSION_VALUE, apiKey, signatureCreator2, timestamp) .getData(); }
java
public List<CoinbaseAccount> getCoinbaseAccounts() throws IOException { String apiKey = exchange.getExchangeSpecification().getApiKey(); BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch(); return coinbase .getAccounts(Coinbase.CB_VERSION_VALUE, apiKey, signatureCreator2, timestamp) .getData(); }
[ "public", "List", "<", "CoinbaseAccount", ">", "getCoinbaseAccounts", "(", ")", "throws", "IOException", "{", "String", "apiKey", "=", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ";", "BigDecimal", "timestamp", "=", "coinbase", ".", "getTime", "(", "Coinbase", ".", "CB_VERSION_VALUE", ")", ".", "getData", "(", ")", ".", "getEpoch", "(", ")", ";", "return", "coinbase", ".", "getAccounts", "(", "Coinbase", ".", "CB_VERSION_VALUE", ",", "apiKey", ",", "signatureCreator2", ",", "timestamp", ")", ".", "getData", "(", ")", ";", "}" ]
Authenticated resource that shows the current user accounts. @see <a href="https://developers.coinbase.com/api/v2#list-accounts">developers.coinbase.com/api/v2#list-accounts</a>
[ "Authenticated", "resource", "that", "shows", "the", "current", "user", "accounts", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/v2/service/CoinbaseAccountServiceRaw.java#L52-L59
15,705
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/v2/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.getCoinbaseAccount
public CoinbaseAccount getCoinbaseAccount(Currency currency) throws IOException { String apiKey = exchange.getExchangeSpecification().getApiKey(); BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch(); return coinbase .getAccount( Coinbase.CB_VERSION_VALUE, apiKey, signatureCreator2, timestamp, currency.getCurrencyCode()) .getData(); }
java
public CoinbaseAccount getCoinbaseAccount(Currency currency) throws IOException { String apiKey = exchange.getExchangeSpecification().getApiKey(); BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch(); return coinbase .getAccount( Coinbase.CB_VERSION_VALUE, apiKey, signatureCreator2, timestamp, currency.getCurrencyCode()) .getData(); }
[ "public", "CoinbaseAccount", "getCoinbaseAccount", "(", "Currency", "currency", ")", "throws", "IOException", "{", "String", "apiKey", "=", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ";", "BigDecimal", "timestamp", "=", "coinbase", ".", "getTime", "(", "Coinbase", ".", "CB_VERSION_VALUE", ")", ".", "getData", "(", ")", ".", "getEpoch", "(", ")", ";", "return", "coinbase", ".", "getAccount", "(", "Coinbase", ".", "CB_VERSION_VALUE", ",", "apiKey", ",", "signatureCreator2", ",", "timestamp", ",", "currency", ".", "getCurrencyCode", "(", ")", ")", ".", "getData", "(", ")", ";", "}" ]
Authenticated resource that shows the current user account for the give currency. @see <a href="https://developers.coinbase.com/api/v2#show-an-account">developers.coinbase.com/api/v2#show-an-account</a>
[ "Authenticated", "resource", "that", "shows", "the", "current", "user", "account", "for", "the", "give", "currency", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/v2/service/CoinbaseAccountServiceRaw.java#L67-L79
15,706
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/v2/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.createCoinbaseAccount
public CoinbaseAccount createCoinbaseAccount(String name) throws IOException { CreateCoinbaseAccountPayload payload = new CreateCoinbaseAccountPayload(name); String path = "/v2/accounts"; String apiKey = exchange.getExchangeSpecification().getApiKey(); BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch(); String body = new ObjectMapper().writeValueAsString(payload); String signature = getSignature(timestamp, HttpMethod.POST, path, body); showCurl(HttpMethod.POST, apiKey, timestamp, signature, path, body); return coinbase .createAccount( MediaType.APPLICATION_JSON, Coinbase.CB_VERSION_VALUE, apiKey, signature, timestamp, payload) .getData(); }
java
public CoinbaseAccount createCoinbaseAccount(String name) throws IOException { CreateCoinbaseAccountPayload payload = new CreateCoinbaseAccountPayload(name); String path = "/v2/accounts"; String apiKey = exchange.getExchangeSpecification().getApiKey(); BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch(); String body = new ObjectMapper().writeValueAsString(payload); String signature = getSignature(timestamp, HttpMethod.POST, path, body); showCurl(HttpMethod.POST, apiKey, timestamp, signature, path, body); return coinbase .createAccount( MediaType.APPLICATION_JSON, Coinbase.CB_VERSION_VALUE, apiKey, signature, timestamp, payload) .getData(); }
[ "public", "CoinbaseAccount", "createCoinbaseAccount", "(", "String", "name", ")", "throws", "IOException", "{", "CreateCoinbaseAccountPayload", "payload", "=", "new", "CreateCoinbaseAccountPayload", "(", "name", ")", ";", "String", "path", "=", "\"/v2/accounts\"", ";", "String", "apiKey", "=", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ";", "BigDecimal", "timestamp", "=", "coinbase", ".", "getTime", "(", "Coinbase", ".", "CB_VERSION_VALUE", ")", ".", "getData", "(", ")", ".", "getEpoch", "(", ")", ";", "String", "body", "=", "new", "ObjectMapper", "(", ")", ".", "writeValueAsString", "(", "payload", ")", ";", "String", "signature", "=", "getSignature", "(", "timestamp", ",", "HttpMethod", ".", "POST", ",", "path", ",", "body", ")", ";", "showCurl", "(", "HttpMethod", ".", "POST", ",", "apiKey", ",", "timestamp", ",", "signature", ",", "path", ",", "body", ")", ";", "return", "coinbase", ".", "createAccount", "(", "MediaType", ".", "APPLICATION_JSON", ",", "Coinbase", ".", "CB_VERSION_VALUE", ",", "apiKey", ",", "signature", ",", "timestamp", ",", "payload", ")", ".", "getData", "(", ")", ";", "}" ]
Authenticated resource that creates a new BTC account for the current user. @see <a href="https://developers.coinbase.com/api/v2#create-account">developers.coinbase.com/api/v2#create-account</a>
[ "Authenticated", "resource", "that", "creates", "a", "new", "BTC", "account", "for", "the", "current", "user", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/v2/service/CoinbaseAccountServiceRaw.java#L87-L107
15,707
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/v2/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.getCoinbasePaymentMethods
public List<CoinbasePaymentMethod> getCoinbasePaymentMethods() throws IOException { String apiKey = exchange.getExchangeSpecification().getApiKey(); BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch(); return coinbase .getPaymentMethods(Coinbase.CB_VERSION_VALUE, apiKey, signatureCreator2, timestamp) .getData(); }
java
public List<CoinbasePaymentMethod> getCoinbasePaymentMethods() throws IOException { String apiKey = exchange.getExchangeSpecification().getApiKey(); BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch(); return coinbase .getPaymentMethods(Coinbase.CB_VERSION_VALUE, apiKey, signatureCreator2, timestamp) .getData(); }
[ "public", "List", "<", "CoinbasePaymentMethod", ">", "getCoinbasePaymentMethods", "(", ")", "throws", "IOException", "{", "String", "apiKey", "=", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ";", "BigDecimal", "timestamp", "=", "coinbase", ".", "getTime", "(", "Coinbase", ".", "CB_VERSION_VALUE", ")", ".", "getData", "(", ")", ".", "getEpoch", "(", ")", ";", "return", "coinbase", ".", "getPaymentMethods", "(", "Coinbase", ".", "CB_VERSION_VALUE", ",", "apiKey", ",", "signatureCreator2", ",", "timestamp", ")", ".", "getData", "(", ")", ";", "}" ]
Authenticated resource that shows the current user payment methods. @see <a href="https://developers.coinbase.com/api/v2#list-payment-methods">developers.coinbase.com/api/v2?shell#list-payment-methods</a>
[ "Authenticated", "resource", "that", "shows", "the", "current", "user", "payment", "methods", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/v2/service/CoinbaseAccountServiceRaw.java#L115-L122
15,708
knowm/XChange
xchange-bitbay/src/main/java/org/knowm/xchange/bitbay/BitbayAdapters.java
BitbayAdapters.adaptTicker
public static Ticker adaptTicker(BitbayTicker bitbayTicker, CurrencyPair currencyPair) { BigDecimal ask = bitbayTicker.getAsk(); BigDecimal bid = bitbayTicker.getBid(); BigDecimal high = bitbayTicker.getMax(); BigDecimal low = bitbayTicker.getMin(); BigDecimal volume = bitbayTicker.getVolume(); BigDecimal last = bitbayTicker.getLast(); return new Ticker.Builder() .currencyPair(currencyPair) .last(last) .bid(bid) .ask(ask) .high(high) .low(low) .volume(volume) .build(); }
java
public static Ticker adaptTicker(BitbayTicker bitbayTicker, CurrencyPair currencyPair) { BigDecimal ask = bitbayTicker.getAsk(); BigDecimal bid = bitbayTicker.getBid(); BigDecimal high = bitbayTicker.getMax(); BigDecimal low = bitbayTicker.getMin(); BigDecimal volume = bitbayTicker.getVolume(); BigDecimal last = bitbayTicker.getLast(); return new Ticker.Builder() .currencyPair(currencyPair) .last(last) .bid(bid) .ask(ask) .high(high) .low(low) .volume(volume) .build(); }
[ "public", "static", "Ticker", "adaptTicker", "(", "BitbayTicker", "bitbayTicker", ",", "CurrencyPair", "currencyPair", ")", "{", "BigDecimal", "ask", "=", "bitbayTicker", ".", "getAsk", "(", ")", ";", "BigDecimal", "bid", "=", "bitbayTicker", ".", "getBid", "(", ")", ";", "BigDecimal", "high", "=", "bitbayTicker", ".", "getMax", "(", ")", ";", "BigDecimal", "low", "=", "bitbayTicker", ".", "getMin", "(", ")", ";", "BigDecimal", "volume", "=", "bitbayTicker", ".", "getVolume", "(", ")", ";", "BigDecimal", "last", "=", "bitbayTicker", ".", "getLast", "(", ")", ";", "return", "new", "Ticker", ".", "Builder", "(", ")", ".", "currencyPair", "(", "currencyPair", ")", ".", "last", "(", "last", ")", ".", "bid", "(", "bid", ")", ".", "ask", "(", "ask", ")", ".", "high", "(", "high", ")", ".", "low", "(", "low", ")", ".", "volume", "(", "volume", ")", ".", "build", "(", ")", ";", "}" ]
Adapts a BitbayTicker to a Ticker Object @param bitbayTicker The exchange specific ticker @param currencyPair (e.g. BTC/USD) @return The ticker
[ "Adapts", "a", "BitbayTicker", "to", "a", "Ticker", "Object" ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-bitbay/src/main/java/org/knowm/xchange/bitbay/BitbayAdapters.java#L45-L63
15,709
knowm/XChange
xchange-coingi/src/main/java/org/knowm/xchange/coingi/service/CoingiDefaultIdentityProvider.java
CoingiDefaultIdentityProvider.getSignature
public synchronized String getSignature(long nonce) { return HexEncoder.encode(sha256HMAC.doFinal(buildSignatureData(nonce))) .toLowerCase(Locale.ROOT); }
java
public synchronized String getSignature(long nonce) { return HexEncoder.encode(sha256HMAC.doFinal(buildSignatureData(nonce))) .toLowerCase(Locale.ROOT); }
[ "public", "synchronized", "String", "getSignature", "(", "long", "nonce", ")", "{", "return", "HexEncoder", ".", "encode", "(", "sha256HMAC", ".", "doFinal", "(", "buildSignatureData", "(", "nonce", ")", ")", ")", ".", "toLowerCase", "(", "Locale", ".", "ROOT", ")", ";", "}" ]
Returns a valid signature for the given nonce. @param nonce Request nonce @return Request signature
[ "Returns", "a", "valid", "signature", "for", "the", "given", "nonce", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coingi/src/main/java/org/knowm/xchange/coingi/service/CoingiDefaultIdentityProvider.java#L64-L67
15,710
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.getCoinbaseUsers
public CoinbaseUsers getCoinbaseUsers() throws IOException { final CoinbaseUsers users = coinbase.getUsers( exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return users; }
java
public CoinbaseUsers getCoinbaseUsers() throws IOException { final CoinbaseUsers users = coinbase.getUsers( exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return users; }
[ "public", "CoinbaseUsers", "getCoinbaseUsers", "(", ")", "throws", "IOException", "{", "final", "CoinbaseUsers", "users", "=", "coinbase", ".", "getUsers", "(", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ")", ";", "return", "users", ";", "}" ]
Authenticated resource that shows the current user and their settings. @return A {@code CoinbaseUsers} wrapper around the current {@code CoinbaseUser} containing account settings. @throws IOException @see <a href="https://coinbase.com/api/doc/1.0/users/index.html">coinbase.com/api/doc/1.0/users/index.html</a>
[ "Authenticated", "resource", "that", "shows", "the", "current", "user", "and", "their", "settings", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java#L48-L56
15,711
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.redeemCoinbaseToken
public boolean redeemCoinbaseToken(String tokenId) throws IOException { final CoinbaseBaseResponse response = coinbase.redeemToken( tokenId, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(response).isSuccess(); }
java
public boolean redeemCoinbaseToken(String tokenId) throws IOException { final CoinbaseBaseResponse response = coinbase.redeemToken( tokenId, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(response).isSuccess(); }
[ "public", "boolean", "redeemCoinbaseToken", "(", "String", "tokenId", ")", "throws", "IOException", "{", "final", "CoinbaseBaseResponse", "response", "=", "coinbase", ".", "redeemToken", "(", "tokenId", ",", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ")", ";", "return", "handleResponse", "(", "response", ")", ".", "isSuccess", "(", ")", ";", "}" ]
Authenticated resource which claims a redeemable token for its address and Bitcoin. @param tokenId @return True if the redemption was successful. @throws IOException @see <a href="https://coinbase.com/api/doc/1.0/tokens/redeem.html">coinbase.com/api/doc/1.0/tokens/redeem.html</a>
[ "Authenticated", "resource", "which", "claims", "a", "redeemable", "token", "for", "its", "address", "and", "Bitcoin", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java#L89-L98
15,712
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.getCoinbaseAddresses
public CoinbaseAddresses getCoinbaseAddresses( Integer page, final Integer limit, final String filter) throws IOException { final CoinbaseAddresses receiveResult = coinbase.getAddresses( page, limit, filter, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return receiveResult; }
java
public CoinbaseAddresses getCoinbaseAddresses( Integer page, final Integer limit, final String filter) throws IOException { final CoinbaseAddresses receiveResult = coinbase.getAddresses( page, limit, filter, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return receiveResult; }
[ "public", "CoinbaseAddresses", "getCoinbaseAddresses", "(", "Integer", "page", ",", "final", "Integer", "limit", ",", "final", "String", "filter", ")", "throws", "IOException", "{", "final", "CoinbaseAddresses", "receiveResult", "=", "coinbase", ".", "getAddresses", "(", "page", ",", "limit", ",", "filter", ",", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ")", ";", "return", "receiveResult", ";", "}" ]
Authenticated resource that returns Bitcoin addresses a user has associated with their account. @param page Optional parameter to request a desired page of results. Will return page 1 if the supplied page is null or less than 1. @param limit Optional parameter to limit the maximum number of results to return. Will return up to 25 results by default if null or less than 1. @param filter Optional String match to filter addresses. Matches the address itself and also if the use has set a ‘label’ on the address. No filter is applied if {@code filter} is null or empty. @return A {@code CoinbaseAddresses} wrapper around a collection of {@code CoinbaseAddress's} associated with the current user's account. @throws IOException @see <a href="https://coinbase.com/api/doc/1.0/addresses/index.html">coinbase.com/api/doc/1.0/addresses/index.html</a>
[ "Authenticated", "resource", "that", "returns", "Bitcoin", "addresses", "a", "user", "has", "associated", "with", "their", "account", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java#L168-L180
15,713
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.generateCoinbaseReceiveAddress
public CoinbaseAddress generateCoinbaseReceiveAddress(String callbackUrl, final String label) throws IOException { final CoinbaseAddressCallback callbackUrlParam = new CoinbaseAddressCallback(callbackUrl, label); final CoinbaseAddress generateReceiveAddress = coinbase.generateReceiveAddress( callbackUrlParam, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(generateReceiveAddress); }
java
public CoinbaseAddress generateCoinbaseReceiveAddress(String callbackUrl, final String label) throws IOException { final CoinbaseAddressCallback callbackUrlParam = new CoinbaseAddressCallback(callbackUrl, label); final CoinbaseAddress generateReceiveAddress = coinbase.generateReceiveAddress( callbackUrlParam, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(generateReceiveAddress); }
[ "public", "CoinbaseAddress", "generateCoinbaseReceiveAddress", "(", "String", "callbackUrl", ",", "final", "String", "label", ")", "throws", "IOException", "{", "final", "CoinbaseAddressCallback", "callbackUrlParam", "=", "new", "CoinbaseAddressCallback", "(", "callbackUrl", ",", "label", ")", ";", "final", "CoinbaseAddress", "generateReceiveAddress", "=", "coinbase", ".", "generateReceiveAddress", "(", "callbackUrlParam", ",", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ")", ";", "return", "handleResponse", "(", "generateReceiveAddress", ")", ";", "}" ]
Authenticated resource that generates a new Bitcoin receive address for the user. @param callbackUrl Optional Callback URL to receive instant payment notifications whenever funds arrive to this address. @param label Optional text label for the address which can be used to filter against when calling {@link #getCoinbaseAddresses}. @return The user’s newly generated and current {@code CoinbaseAddress}. @throws IOException @see <a href="https://coinbase.com/api/doc/1.0/accounts/generate_receive_address.html">coinbase.com/api/doc/1.0/accounts/generate_receive_address .html</a>
[ "Authenticated", "resource", "that", "generates", "a", "new", "Bitcoin", "receive", "address", "for", "the", "user", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java#L209-L222
15,714
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.getCoinbaseContacts
public CoinbaseContacts getCoinbaseContacts( Integer page, final Integer limit, final String filter) throws IOException { final CoinbaseContacts contacts = coinbase.getContacts( page, limit, filter, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return contacts; }
java
public CoinbaseContacts getCoinbaseContacts( Integer page, final Integer limit, final String filter) throws IOException { final CoinbaseContacts contacts = coinbase.getContacts( page, limit, filter, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return contacts; }
[ "public", "CoinbaseContacts", "getCoinbaseContacts", "(", "Integer", "page", ",", "final", "Integer", "limit", ",", "final", "String", "filter", ")", "throws", "IOException", "{", "final", "CoinbaseContacts", "contacts", "=", "coinbase", ".", "getContacts", "(", "page", ",", "limit", ",", "filter", ",", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ")", ";", "return", "contacts", ";", "}" ]
Authenticated resource that returns contacts the user has previously sent to or received from. @param page Optional parameter to request a desired page of results. Will return page 1 if the supplied page is null or less than 1. @param limit Optional parameter to limit the maximum number of results to return. Will return up to 25 results by default if null or less than 1. @param filter Optional String match to filter addresses. Matches the address itself and also if the use has set a ‘label’ on the address. No filter is applied if {@code filter} is null or empty. @return {@code CoinbaseContacts} the user has previously sent to or received from. @throws IOException @see <a href="https://coinbase.com/api/doc/1.0/contacts/index.html">coinbase.com/api/doc/1.0/contacts/index.html</a>
[ "Authenticated", "resource", "that", "returns", "contacts", "the", "user", "has", "previously", "sent", "to", "or", "received", "from", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java#L292-L304
15,715
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.getCoinbaseTransaction
public CoinbaseTransaction getCoinbaseTransaction(String transactionIdOrIdemField) throws IOException { final CoinbaseTransaction transaction = coinbase.getTransactionDetails( transactionIdOrIdemField, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(transaction); }
java
public CoinbaseTransaction getCoinbaseTransaction(String transactionIdOrIdemField) throws IOException { final CoinbaseTransaction transaction = coinbase.getTransactionDetails( transactionIdOrIdemField, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(transaction); }
[ "public", "CoinbaseTransaction", "getCoinbaseTransaction", "(", "String", "transactionIdOrIdemField", ")", "throws", "IOException", "{", "final", "CoinbaseTransaction", "transaction", "=", "coinbase", ".", "getTransactionDetails", "(", "transactionIdOrIdemField", ",", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ")", ";", "return", "handleResponse", "(", "transaction", ")", ";", "}" ]
Authenticated resource which returns the details of an individual transaction. @param transactionIdOrIdemField @return @throws IOException @see <a href="https://coinbase.com/api/doc/1.0/transactions/show.html">coinbase.com/api/doc/1.0/transactions/show.html</a>
[ "Authenticated", "resource", "which", "returns", "the", "details", "of", "an", "individual", "transaction", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java#L351-L361
15,716
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.requestMoneyCoinbaseRequest
public CoinbaseTransaction requestMoneyCoinbaseRequest( CoinbaseRequestMoneyRequest transactionRequest) throws IOException { final CoinbaseTransaction pendingTransaction = coinbase.requestMoney( new CoinbaseTransaction(transactionRequest), exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(pendingTransaction); }
java
public CoinbaseTransaction requestMoneyCoinbaseRequest( CoinbaseRequestMoneyRequest transactionRequest) throws IOException { final CoinbaseTransaction pendingTransaction = coinbase.requestMoney( new CoinbaseTransaction(transactionRequest), exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(pendingTransaction); }
[ "public", "CoinbaseTransaction", "requestMoneyCoinbaseRequest", "(", "CoinbaseRequestMoneyRequest", "transactionRequest", ")", "throws", "IOException", "{", "final", "CoinbaseTransaction", "pendingTransaction", "=", "coinbase", ".", "requestMoney", "(", "new", "CoinbaseTransaction", "(", "transactionRequest", ")", ",", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ")", ";", "return", "handleResponse", "(", "pendingTransaction", ")", ";", "}" ]
Authenticated resource which lets the user request money from a Bitcoin address. @param transactionRequest @return A pending {@code CoinbaseTransaction} representing the desired {@code CoinbaseRequestMoneyRequest}. @throws IOException @see <a href="https://coinbase.com/api/doc/1.0/transactions/request_money.html">coinbase.com/api/doc/1.0/transactions/request_money.html</a>
[ "Authenticated", "resource", "which", "lets", "the", "user", "request", "money", "from", "a", "Bitcoin", "address", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java#L373-L383
15,717
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.sendMoneyCoinbaseRequest
public CoinbaseTransaction sendMoneyCoinbaseRequest(CoinbaseSendMoneyRequest transactionRequest) throws IOException { final CoinbaseTransaction pendingTransaction = coinbase.sendMoney( new CoinbaseTransaction(transactionRequest), exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(pendingTransaction); }
java
public CoinbaseTransaction sendMoneyCoinbaseRequest(CoinbaseSendMoneyRequest transactionRequest) throws IOException { final CoinbaseTransaction pendingTransaction = coinbase.sendMoney( new CoinbaseTransaction(transactionRequest), exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(pendingTransaction); }
[ "public", "CoinbaseTransaction", "sendMoneyCoinbaseRequest", "(", "CoinbaseSendMoneyRequest", "transactionRequest", ")", "throws", "IOException", "{", "final", "CoinbaseTransaction", "pendingTransaction", "=", "coinbase", ".", "sendMoney", "(", "new", "CoinbaseTransaction", "(", "transactionRequest", ")", ",", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ")", ";", "return", "handleResponse", "(", "pendingTransaction", ")", ";", "}" ]
Authenticated resource which lets you send money to an email or Bitcoin address. @param transactionRequest @return A completed {@code CoinbaseTransaction} representing the desired {@code CoinbaseSendMoneyRequest}. @throws IOException @see <a href="https://coinbase.com/api/doc/1.0/transactions/send_money.html">coinbase.com/api/doc/1.0/transactions/send_money.html</a>
[ "Authenticated", "resource", "which", "lets", "you", "send", "money", "to", "an", "email", "or", "Bitcoin", "address", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java#L395-L405
15,718
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.resendCoinbaseRequest
public CoinbaseBaseResponse resendCoinbaseRequest(String transactionId) throws IOException { final CoinbaseBaseResponse response = coinbase.resendRequest( transactionId, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(response); }
java
public CoinbaseBaseResponse resendCoinbaseRequest(String transactionId) throws IOException { final CoinbaseBaseResponse response = coinbase.resendRequest( transactionId, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(response); }
[ "public", "CoinbaseBaseResponse", "resendCoinbaseRequest", "(", "String", "transactionId", ")", "throws", "IOException", "{", "final", "CoinbaseBaseResponse", "response", "=", "coinbase", ".", "resendRequest", "(", "transactionId", ",", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ")", ";", "return", "handleResponse", "(", "response", ")", ";", "}" ]
Authenticated resource which lets the user resend a money request. @param transactionId @return true if resending the request was successful. @throws IOException @see <a href="https://coinbase.com/api/doc/1.0/transactions/resend_request.html">coinbase.com/api/doc/1.0/transactions/resend_request.html</a>
[ "Authenticated", "resource", "which", "lets", "the", "user", "resend", "a", "money", "request", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java#L416-L425
15,719
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.cancelCoinbaseRequest
public CoinbaseBaseResponse cancelCoinbaseRequest(String transactionId) throws IOException { final CoinbaseBaseResponse response = coinbase.cancelRequest( transactionId, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(response); }
java
public CoinbaseBaseResponse cancelCoinbaseRequest(String transactionId) throws IOException { final CoinbaseBaseResponse response = coinbase.cancelRequest( transactionId, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(response); }
[ "public", "CoinbaseBaseResponse", "cancelCoinbaseRequest", "(", "String", "transactionId", ")", "throws", "IOException", "{", "final", "CoinbaseBaseResponse", "response", "=", "coinbase", ".", "cancelRequest", "(", "transactionId", ",", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ")", ";", "return", "handleResponse", "(", "response", ")", ";", "}" ]
Authenticated resource which lets a user cancel a money request. Money requests can be canceled by the sender or the recipient. @param transactionId @return true if canceling the request was successful. @throws IOException @see <a href="https://coinbase.com/api/doc/1.0/transactions/cancel_request.html">coinbase.com/api/doc/1.0/transactions/cancel_request.html</a>
[ "Authenticated", "resource", "which", "lets", "a", "user", "cancel", "a", "money", "request", ".", "Money", "requests", "can", "be", "canceled", "by", "the", "sender", "or", "the", "recipient", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java#L461-L470
15,720
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.createCoinbaseButton
public CoinbaseButton createCoinbaseButton(CoinbaseButton button) throws IOException { final CoinbaseButton createdButton = coinbase.createButton( button, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(createdButton); }
java
public CoinbaseButton createCoinbaseButton(CoinbaseButton button) throws IOException { final CoinbaseButton createdButton = coinbase.createButton( button, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(createdButton); }
[ "public", "CoinbaseButton", "createCoinbaseButton", "(", "CoinbaseButton", "button", ")", "throws", "IOException", "{", "final", "CoinbaseButton", "createdButton", "=", "coinbase", ".", "createButton", "(", "button", ",", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ")", ";", "return", "handleResponse", "(", "createdButton", ")", ";", "}" ]
Authenticated resource that creates a payment button, page, or iFrame to accept Bitcoin on your website. This can be used to accept Bitcoin for an individual item or to integrate with your existing shopping cart solution. For example, you could create a new payment button for each shopping cart on your website, setting the total and order number in the button at checkout. @param button A {@code CoinbaseButton} containing the desired button configuration for Coinbase to create. @return newly created {@code CoinbaseButton}. @throws IOException @see <a href="https://coinbase.com/api/doc/1.0/buttons/create.html">coinbase.com/api/doc/1.0/buttons/create.html</a>
[ "Authenticated", "resource", "that", "creates", "a", "payment", "button", "page", "or", "iFrame", "to", "accept", "Bitcoin", "on", "your", "website", ".", "This", "can", "be", "used", "to", "accept", "Bitcoin", "for", "an", "individual", "item", "or", "to", "integrate", "with", "your", "existing", "shopping", "cart", "solution", ".", "For", "example", "you", "could", "create", "a", "new", "payment", "button", "for", "each", "shopping", "cart", "on", "your", "website", "setting", "the", "total", "and", "order", "number", "in", "the", "button", "at", "checkout", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java#L485-L494
15,721
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.getCoinbaseOrder
public CoinbaseOrder getCoinbaseOrder(String orderIdOrCustom) throws IOException { final CoinbaseOrder order = coinbase.getOrder( orderIdOrCustom, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(order); }
java
public CoinbaseOrder getCoinbaseOrder(String orderIdOrCustom) throws IOException { final CoinbaseOrder order = coinbase.getOrder( orderIdOrCustom, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(order); }
[ "public", "CoinbaseOrder", "getCoinbaseOrder", "(", "String", "orderIdOrCustom", ")", "throws", "IOException", "{", "final", "CoinbaseOrder", "order", "=", "coinbase", ".", "getOrder", "(", "orderIdOrCustom", ",", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ")", ";", "return", "handleResponse", "(", "order", ")", ";", "}" ]
Authenticated resource which returns order details for a specific order id or merchant custom. @param orderIdOrCustom @return @throws IOException @see <a href="https://coinbase.com/api/doc/1.0/orders/show.html">coinbase.com/api/doc/1.0/orders/show.html</a>
[ "Authenticated", "resource", "which", "returns", "order", "details", "for", "a", "specific", "order", "id", "or", "merchant", "custom", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java#L542-L551
15,722
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.createCoinbaseOrder
public CoinbaseOrder createCoinbaseOrder(CoinbaseButton button) throws IOException { final CoinbaseOrder createdOrder = coinbase.createOrder( button, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(createdOrder); }
java
public CoinbaseOrder createCoinbaseOrder(CoinbaseButton button) throws IOException { final CoinbaseOrder createdOrder = coinbase.createOrder( button, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return handleResponse(createdOrder); }
[ "public", "CoinbaseOrder", "createCoinbaseOrder", "(", "CoinbaseButton", "button", ")", "throws", "IOException", "{", "final", "CoinbaseOrder", "createdOrder", "=", "coinbase", ".", "createOrder", "(", "button", ",", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ")", ";", "return", "handleResponse", "(", "createdOrder", ")", ";", "}" ]
Authenticated resource which returns an order for a new button. @param button A {@code CoinbaseButton} containing information to create a one time order. @return The newly created {@code CoinbaseOrder}. @throws IOException @see <a href="https://coinbase.com/api/doc/1.0/orders/create.html">coinbase.com/api/doc/1.0/orders/create.html</a>
[ "Authenticated", "resource", "which", "returns", "an", "order", "for", "a", "new", "button", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java#L584-L593
15,723
knowm/XChange
xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java
CoinbaseAccountServiceRaw.getCoinbaseRecurringPayment
public CoinbaseRecurringPayment getCoinbaseRecurringPayment(String recurringPaymentId) throws IOException { final CoinbaseRecurringPayment recurringPayment = coinbase.getRecurringPayment( recurringPaymentId, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return recurringPayment; }
java
public CoinbaseRecurringPayment getCoinbaseRecurringPayment(String recurringPaymentId) throws IOException { final CoinbaseRecurringPayment recurringPayment = coinbase.getRecurringPayment( recurringPaymentId, exchange.getExchangeSpecification().getApiKey(), signatureCreator, exchange.getNonceFactory()); return recurringPayment; }
[ "public", "CoinbaseRecurringPayment", "getCoinbaseRecurringPayment", "(", "String", "recurringPaymentId", ")", "throws", "IOException", "{", "final", "CoinbaseRecurringPayment", "recurringPayment", "=", "coinbase", ".", "getRecurringPayment", "(", "recurringPaymentId", ",", "exchange", ".", "getExchangeSpecification", "(", ")", ".", "getApiKey", "(", ")", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ")", ";", "return", "recurringPayment", ";", "}" ]
Authenticated resource that lets you show an individual recurring payment. @param recurringPaymentId @return @throws IOException @see <a href="https://coinbase.com/api/doc/1.0/recurring_payments/show.html">coinbase.com/api/doc/1.0/recurring_payments/show.html</a>
[ "Authenticated", "resource", "that", "lets", "you", "show", "an", "individual", "recurring", "payment", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-coinbase/src/main/java/org/knowm/xchange/coinbase/service/CoinbaseAccountServiceRaw.java#L645-L655
15,724
knowm/XChange
xchange-dsx/src/main/java/org/knowm/xchange/dsx/service/core/DSXTradeServiceCoreRaw.java
DSXTradeServiceCoreRaw.getDSXTradeHistory
public Map<Long, DSXTradeHistoryResult> getDSXTradeHistory( Integer count, Long fromId, Long endId, DSXAuthenticatedV2.SortOrder order, Long since, Long end, String pair) throws IOException { DSXTradeHistoryReturn dsxTradeHistory = dsx.tradeHistory( apiKey, signatureCreator, exchange.getNonceFactory(), count, fromId, endId, order, since, end, pair); String error = dsxTradeHistory.getError(); if (MSG_NO_TRADES.equals(error)) { return Collections.emptyMap(); } checkResult(dsxTradeHistory); return dsxTradeHistory.getReturnValue(); }
java
public Map<Long, DSXTradeHistoryResult> getDSXTradeHistory( Integer count, Long fromId, Long endId, DSXAuthenticatedV2.SortOrder order, Long since, Long end, String pair) throws IOException { DSXTradeHistoryReturn dsxTradeHistory = dsx.tradeHistory( apiKey, signatureCreator, exchange.getNonceFactory(), count, fromId, endId, order, since, end, pair); String error = dsxTradeHistory.getError(); if (MSG_NO_TRADES.equals(error)) { return Collections.emptyMap(); } checkResult(dsxTradeHistory); return dsxTradeHistory.getReturnValue(); }
[ "public", "Map", "<", "Long", ",", "DSXTradeHistoryResult", ">", "getDSXTradeHistory", "(", "Integer", "count", ",", "Long", "fromId", ",", "Long", "endId", ",", "DSXAuthenticatedV2", ".", "SortOrder", "order", ",", "Long", "since", ",", "Long", "end", ",", "String", "pair", ")", "throws", "IOException", "{", "DSXTradeHistoryReturn", "dsxTradeHistory", "=", "dsx", ".", "tradeHistory", "(", "apiKey", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ",", "count", ",", "fromId", ",", "endId", ",", "order", ",", "since", ",", "end", ",", "pair", ")", ";", "String", "error", "=", "dsxTradeHistory", ".", "getError", "(", ")", ";", "if", "(", "MSG_NO_TRADES", ".", "equals", "(", "error", ")", ")", "{", "return", "Collections", ".", "emptyMap", "(", ")", ";", "}", "checkResult", "(", "dsxTradeHistory", ")", ";", "return", "dsxTradeHistory", ".", "getReturnValue", "(", ")", ";", "}" ]
Get Map of trade history from DSX exchange. All parameters are nullable @param count Number of trades to display @param fromId ID of the first trade of the selection @param endId ID of the last trade of the selection @param order Order in which transactions shown. Possible values: «asc» — from first to last, «desc» — from last to first. Default value is «desc» @param since Time from which start selecting trades by trade time(UNIX time). If this value is not null order will become «asc» @param end Time to which start selecting trades by trade time(UNIX time). If this value is not null order will become «asc» @param pair Currency pair @return Map of trade history result @throws IOException
[ "Get", "Map", "of", "trade", "history", "from", "DSX", "exchange", ".", "All", "parameters", "are", "nullable" ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-dsx/src/main/java/org/knowm/xchange/dsx/service/core/DSXTradeServiceCoreRaw.java#L142-L171
15,725
knowm/XChange
xchange-dsx/src/main/java/org/knowm/xchange/dsx/service/core/DSXTradeServiceCoreRaw.java
DSXTradeServiceCoreRaw.getDSXTransHistory
public Map<Long, DSXTransHistoryResult> getDSXTransHistory( Integer count, Long fromId, Long endId, DSXAuthenticatedV2.SortOrder order, Long since, Long end, DSXTransHistoryResult.Type type, DSXTransHistoryResult.Status status, String currency) throws IOException { DSXTransHistoryReturn dsxTransHistory = dsx.transHistory( apiKey, signatureCreator, exchange.getNonceFactory(), count, fromId, endId, order, since, end, type, status, currency); String error = dsxTransHistory.getError(); if (MSG_NO_TRADES.equals(error)) { return Collections.emptyMap(); } checkResult(dsxTransHistory); return dsxTransHistory.getReturnValue(); }
java
public Map<Long, DSXTransHistoryResult> getDSXTransHistory( Integer count, Long fromId, Long endId, DSXAuthenticatedV2.SortOrder order, Long since, Long end, DSXTransHistoryResult.Type type, DSXTransHistoryResult.Status status, String currency) throws IOException { DSXTransHistoryReturn dsxTransHistory = dsx.transHistory( apiKey, signatureCreator, exchange.getNonceFactory(), count, fromId, endId, order, since, end, type, status, currency); String error = dsxTransHistory.getError(); if (MSG_NO_TRADES.equals(error)) { return Collections.emptyMap(); } checkResult(dsxTransHistory); return dsxTransHistory.getReturnValue(); }
[ "public", "Map", "<", "Long", ",", "DSXTransHistoryResult", ">", "getDSXTransHistory", "(", "Integer", "count", ",", "Long", "fromId", ",", "Long", "endId", ",", "DSXAuthenticatedV2", ".", "SortOrder", "order", ",", "Long", "since", ",", "Long", "end", ",", "DSXTransHistoryResult", ".", "Type", "type", ",", "DSXTransHistoryResult", ".", "Status", "status", ",", "String", "currency", ")", "throws", "IOException", "{", "DSXTransHistoryReturn", "dsxTransHistory", "=", "dsx", ".", "transHistory", "(", "apiKey", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ",", "count", ",", "fromId", ",", "endId", ",", "order", ",", "since", ",", "end", ",", "type", ",", "status", ",", "currency", ")", ";", "String", "error", "=", "dsxTransHistory", ".", "getError", "(", ")", ";", "if", "(", "MSG_NO_TRADES", ".", "equals", "(", "error", ")", ")", "{", "return", "Collections", ".", "emptyMap", "(", ")", ";", "}", "checkResult", "(", "dsxTransHistory", ")", ";", "return", "dsxTransHistory", ".", "getReturnValue", "(", ")", ";", "}" ]
Get Map of transaction history from DSX exchange. All parameters are nullable @param count Number of transactions to display. Default value is 1000 @param fromId ID of the first transaction of the selection @param endId ID of the last transaction of the selection @param order Order in which transactions shown. Possible values: «asc» — from first to last, «desc» — from last to first. Default value is «desc» @param since Time from which start selecting transaction by transaction time(UNIX time). If this value is not null order will become «asc» @param end Time to which start selecting transaction by transaction time(UNIX time). If this value is not null order will become «asc» @return Map of transaction history @throws IOException
[ "Get", "Map", "of", "transaction", "history", "from", "DSX", "exchange", ".", "All", "parameters", "are", "nullable" ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-dsx/src/main/java/org/knowm/xchange/dsx/service/core/DSXTradeServiceCoreRaw.java#L188-L221
15,726
knowm/XChange
xchange-dsx/src/main/java/org/knowm/xchange/dsx/service/core/DSXTradeServiceCoreRaw.java
DSXTradeServiceCoreRaw.getDSXOrderHistory
public Map<Long, DSXOrderHistoryResult> getDSXOrderHistory( Long count, Long fromId, Long endId, DSXAuthenticatedV2.SortOrder order, Long since, Long end, String pair) throws IOException { DSXOrderHistoryReturn dsxOrderHistory = dsx.orderHistory( apiKey, signatureCreator, exchange.getNonceFactory(), count, fromId, endId, order, since, end, pair); String error = dsxOrderHistory.getError(); if (MSG_NO_TRADES.equals(error)) { return Collections.emptyMap(); } checkResult(dsxOrderHistory); return dsxOrderHistory.getReturnValue(); }
java
public Map<Long, DSXOrderHistoryResult> getDSXOrderHistory( Long count, Long fromId, Long endId, DSXAuthenticatedV2.SortOrder order, Long since, Long end, String pair) throws IOException { DSXOrderHistoryReturn dsxOrderHistory = dsx.orderHistory( apiKey, signatureCreator, exchange.getNonceFactory(), count, fromId, endId, order, since, end, pair); String error = dsxOrderHistory.getError(); if (MSG_NO_TRADES.equals(error)) { return Collections.emptyMap(); } checkResult(dsxOrderHistory); return dsxOrderHistory.getReturnValue(); }
[ "public", "Map", "<", "Long", ",", "DSXOrderHistoryResult", ">", "getDSXOrderHistory", "(", "Long", "count", ",", "Long", "fromId", ",", "Long", "endId", ",", "DSXAuthenticatedV2", ".", "SortOrder", "order", ",", "Long", "since", ",", "Long", "end", ",", "String", "pair", ")", "throws", "IOException", "{", "DSXOrderHistoryReturn", "dsxOrderHistory", "=", "dsx", ".", "orderHistory", "(", "apiKey", ",", "signatureCreator", ",", "exchange", ".", "getNonceFactory", "(", ")", ",", "count", ",", "fromId", ",", "endId", ",", "order", ",", "since", ",", "end", ",", "pair", ")", ";", "String", "error", "=", "dsxOrderHistory", ".", "getError", "(", ")", ";", "if", "(", "MSG_NO_TRADES", ".", "equals", "(", "error", ")", ")", "{", "return", "Collections", ".", "emptyMap", "(", ")", ";", "}", "checkResult", "(", "dsxOrderHistory", ")", ";", "return", "dsxOrderHistory", ".", "getReturnValue", "(", ")", ";", "}" ]
Get Map of order history from DSX exchange. All parameters are nullable @param count Number of orders to display. Default value is 1000 @param fromId ID of the first order of the selection @param endId ID of the last order of the selection @param order Order in which transactions shown. Possible values: «asc» — from first to last, «desc» — from last to first. Default value is «desc» @param since Time from which start selecting orders by trade time(UNIX time). If this value is not null order will become «asc» @param end Time to which start selecting orders by trade time(UNIX time). If this value is not null order will become «asc» @param pair Currency pair @return Map of order history @throws IOException
[ "Get", "Map", "of", "order", "history", "from", "DSX", "exchange", ".", "All", "parameters", "are", "nullable" ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-dsx/src/main/java/org/knowm/xchange/dsx/service/core/DSXTradeServiceCoreRaw.java#L239-L268
15,727
knowm/XChange
xchange-bitfinex/src/main/java/org/knowm/xchange/bitfinex/v1/BitfinexAdapters.java
BitfinexAdapters.adaptDynamicTradingFees
public static Map<CurrencyPair, Fee> adaptDynamicTradingFees( BitfinexTradingFeeResponse[] responses, List<CurrencyPair> currencyPairs) { Map<CurrencyPair, Fee> result = new HashMap<>(); for (BitfinexTradingFeeResponse response : responses) { BitfinexTradingFeeResponse.BitfinexTradingFeeResponseRow[] responseRows = response.getTradingFees(); for (BitfinexTradingFeeResponse.BitfinexTradingFeeResponseRow responseRow : responseRows) { Currency currency = Currency.getInstance(responseRow.getCurrency()); BigDecimal percentToFraction = BigDecimal.ONE.divide(BigDecimal.ONE.scaleByPowerOfTen(2)); Fee fee = new Fee( responseRow.getMakerFee().multiply(percentToFraction), responseRow.getTakerFee().multiply(percentToFraction)); for (CurrencyPair pair : currencyPairs) { // Fee to trade for a currency is the fee to trade currency pairs with this base. // Fee is typically assessed in units counter. if (pair.base.equals(currency)) { if (result.put(pair, fee) != null) { throw new IllegalStateException( "Fee for currency pair " + pair + " is overspecified"); } } } } } return result; }
java
public static Map<CurrencyPair, Fee> adaptDynamicTradingFees( BitfinexTradingFeeResponse[] responses, List<CurrencyPair> currencyPairs) { Map<CurrencyPair, Fee> result = new HashMap<>(); for (BitfinexTradingFeeResponse response : responses) { BitfinexTradingFeeResponse.BitfinexTradingFeeResponseRow[] responseRows = response.getTradingFees(); for (BitfinexTradingFeeResponse.BitfinexTradingFeeResponseRow responseRow : responseRows) { Currency currency = Currency.getInstance(responseRow.getCurrency()); BigDecimal percentToFraction = BigDecimal.ONE.divide(BigDecimal.ONE.scaleByPowerOfTen(2)); Fee fee = new Fee( responseRow.getMakerFee().multiply(percentToFraction), responseRow.getTakerFee().multiply(percentToFraction)); for (CurrencyPair pair : currencyPairs) { // Fee to trade for a currency is the fee to trade currency pairs with this base. // Fee is typically assessed in units counter. if (pair.base.equals(currency)) { if (result.put(pair, fee) != null) { throw new IllegalStateException( "Fee for currency pair " + pair + " is overspecified"); } } } } } return result; }
[ "public", "static", "Map", "<", "CurrencyPair", ",", "Fee", ">", "adaptDynamicTradingFees", "(", "BitfinexTradingFeeResponse", "[", "]", "responses", ",", "List", "<", "CurrencyPair", ">", "currencyPairs", ")", "{", "Map", "<", "CurrencyPair", ",", "Fee", ">", "result", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "BitfinexTradingFeeResponse", "response", ":", "responses", ")", "{", "BitfinexTradingFeeResponse", ".", "BitfinexTradingFeeResponseRow", "[", "]", "responseRows", "=", "response", ".", "getTradingFees", "(", ")", ";", "for", "(", "BitfinexTradingFeeResponse", ".", "BitfinexTradingFeeResponseRow", "responseRow", ":", "responseRows", ")", "{", "Currency", "currency", "=", "Currency", ".", "getInstance", "(", "responseRow", ".", "getCurrency", "(", ")", ")", ";", "BigDecimal", "percentToFraction", "=", "BigDecimal", ".", "ONE", ".", "divide", "(", "BigDecimal", ".", "ONE", ".", "scaleByPowerOfTen", "(", "2", ")", ")", ";", "Fee", "fee", "=", "new", "Fee", "(", "responseRow", ".", "getMakerFee", "(", ")", ".", "multiply", "(", "percentToFraction", ")", ",", "responseRow", ".", "getTakerFee", "(", ")", ".", "multiply", "(", "percentToFraction", ")", ")", ";", "for", "(", "CurrencyPair", "pair", ":", "currencyPairs", ")", "{", "// Fee to trade for a currency is the fee to trade currency pairs with this base.", "// Fee is typically assessed in units counter.", "if", "(", "pair", ".", "base", ".", "equals", "(", "currency", ")", ")", "{", "if", "(", "result", ".", "put", "(", "pair", ",", "fee", ")", "!=", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Fee for currency pair \"", "+", "pair", "+", "\" is overspecified\"", ")", ";", "}", "}", "}", "}", "}", "return", "result", ";", "}" ]
Each element in the response array contains a set of currencies that are at a given fee tier. The API returns the fee per currency in each tier and does not make any promises that they are all the same, so this adapter will use the fee per currency instead of the fee per tier.
[ "Each", "element", "in", "the", "response", "array", "contains", "a", "set", "of", "currencies", "that", "are", "at", "a", "given", "fee", "tier", ".", "The", "API", "returns", "the", "fee", "per", "currency", "in", "each", "tier", "and", "does", "not", "make", "any", "promises", "that", "they", "are", "all", "the", "same", "so", "this", "adapter", "will", "use", "the", "fee", "per", "currency", "instead", "of", "the", "fee", "per", "tier", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-bitfinex/src/main/java/org/knowm/xchange/bitfinex/v1/BitfinexAdapters.java#L72-L98
15,728
knowm/XChange
xchange-ripple/src/main/java/org/knowm/xchange/ripple/service/RippleTradeServiceRaw.java
RippleTradeServiceRaw.getTrade
public IRippleTradeTransaction getTrade( final String account, final RippleNotification notification) throws RippleException, IOException { final RippleExchange ripple = (RippleExchange) exchange; if (ripple.isStoreTradeTransactionDetails()) { Map<String, IRippleTradeTransaction> cache = rawTradeStore.get(account); if (cache == null) { cache = new ConcurrentHashMap<>(); rawTradeStore.put(account, cache); } if (cache.containsKey(notification.getHash())) { return cache.get(notification.getHash()); } } final IRippleTradeTransaction trade; try { if (notification.getType().equals("order")) { trade = ripplePublic.orderTransaction(account, notification.getHash()); } else if (notification.getType().equals("payment")) { trade = ripplePublic.paymentTransaction(account, notification.getHash()); } else { throw new IllegalArgumentException( String.format( "unexpected notification %s type for transaction[%s] and account[%s]", notification.getType(), notification.getHash(), notification.getAccount())); } } catch (final RippleException e) { if (e.getHttpStatusCode() == 500 && e.getErrorType().equals("transaction")) { // Do not let an individual transaction parsing bug in the Ripple REST service cause a total // trade // history failure. See https://github.com/ripple/ripple-rest/issues/384 as an example of // this situation. logger.error( "exception reading {} transaction[{}] for account[{}]", notification.getType(), notification.getHash(), account, e); return null; } else { throw e; } } if (ripple.isStoreTradeTransactionDetails()) { rawTradeStore.get(account).put(notification.getHash(), trade); } return trade; }
java
public IRippleTradeTransaction getTrade( final String account, final RippleNotification notification) throws RippleException, IOException { final RippleExchange ripple = (RippleExchange) exchange; if (ripple.isStoreTradeTransactionDetails()) { Map<String, IRippleTradeTransaction> cache = rawTradeStore.get(account); if (cache == null) { cache = new ConcurrentHashMap<>(); rawTradeStore.put(account, cache); } if (cache.containsKey(notification.getHash())) { return cache.get(notification.getHash()); } } final IRippleTradeTransaction trade; try { if (notification.getType().equals("order")) { trade = ripplePublic.orderTransaction(account, notification.getHash()); } else if (notification.getType().equals("payment")) { trade = ripplePublic.paymentTransaction(account, notification.getHash()); } else { throw new IllegalArgumentException( String.format( "unexpected notification %s type for transaction[%s] and account[%s]", notification.getType(), notification.getHash(), notification.getAccount())); } } catch (final RippleException e) { if (e.getHttpStatusCode() == 500 && e.getErrorType().equals("transaction")) { // Do not let an individual transaction parsing bug in the Ripple REST service cause a total // trade // history failure. See https://github.com/ripple/ripple-rest/issues/384 as an example of // this situation. logger.error( "exception reading {} transaction[{}] for account[{}]", notification.getType(), notification.getHash(), account, e); return null; } else { throw e; } } if (ripple.isStoreTradeTransactionDetails()) { rawTradeStore.get(account).put(notification.getHash(), trade); } return trade; }
[ "public", "IRippleTradeTransaction", "getTrade", "(", "final", "String", "account", ",", "final", "RippleNotification", "notification", ")", "throws", "RippleException", ",", "IOException", "{", "final", "RippleExchange", "ripple", "=", "(", "RippleExchange", ")", "exchange", ";", "if", "(", "ripple", ".", "isStoreTradeTransactionDetails", "(", ")", ")", "{", "Map", "<", "String", ",", "IRippleTradeTransaction", ">", "cache", "=", "rawTradeStore", ".", "get", "(", "account", ")", ";", "if", "(", "cache", "==", "null", ")", "{", "cache", "=", "new", "ConcurrentHashMap", "<>", "(", ")", ";", "rawTradeStore", ".", "put", "(", "account", ",", "cache", ")", ";", "}", "if", "(", "cache", ".", "containsKey", "(", "notification", ".", "getHash", "(", ")", ")", ")", "{", "return", "cache", ".", "get", "(", "notification", ".", "getHash", "(", ")", ")", ";", "}", "}", "final", "IRippleTradeTransaction", "trade", ";", "try", "{", "if", "(", "notification", ".", "getType", "(", ")", ".", "equals", "(", "\"order\"", ")", ")", "{", "trade", "=", "ripplePublic", ".", "orderTransaction", "(", "account", ",", "notification", ".", "getHash", "(", ")", ")", ";", "}", "else", "if", "(", "notification", ".", "getType", "(", ")", ".", "equals", "(", "\"payment\"", ")", ")", "{", "trade", "=", "ripplePublic", ".", "paymentTransaction", "(", "account", ",", "notification", ".", "getHash", "(", ")", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"unexpected notification %s type for transaction[%s] and account[%s]\"", ",", "notification", ".", "getType", "(", ")", ",", "notification", ".", "getHash", "(", ")", ",", "notification", ".", "getAccount", "(", ")", ")", ")", ";", "}", "}", "catch", "(", "final", "RippleException", "e", ")", "{", "if", "(", "e", ".", "getHttpStatusCode", "(", ")", "==", "500", "&&", "e", ".", "getErrorType", "(", ")", ".", "equals", "(", "\"transaction\"", ")", ")", "{", "// Do not let an individual transaction parsing bug in the Ripple REST service cause a total", "// trade", "// history failure. See https://github.com/ripple/ripple-rest/issues/384 as an example of", "// this situation.", "logger", ".", "error", "(", "\"exception reading {} transaction[{}] for account[{}]\"", ",", "notification", ".", "getType", "(", ")", ",", "notification", ".", "getHash", "(", ")", ",", "account", ",", "e", ")", ";", "return", "null", ";", "}", "else", "{", "throw", "e", ";", "}", "}", "if", "(", "ripple", ".", "isStoreTradeTransactionDetails", "(", ")", ")", "{", "rawTradeStore", ".", "get", "(", "account", ")", ".", "put", "(", "notification", ".", "getHash", "(", ")", ",", "trade", ")", ";", "}", "return", "trade", ";", "}" ]
Retrieve order details from local store if they have been previously stored otherwise query external server.
[ "Retrieve", "order", "details", "from", "local", "store", "if", "they", "have", "been", "previously", "stored", "otherwise", "query", "external", "server", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-ripple/src/main/java/org/knowm/xchange/ripple/service/RippleTradeServiceRaw.java#L175-L224
15,729
knowm/XChange
xchange-ripple/src/main/java/org/knowm/xchange/ripple/service/RippleTradeServiceRaw.java
RippleTradeServiceRaw.clearOrderDetailsStore
public void clearOrderDetailsStore() { for (final Map<String, IRippleTradeTransaction> cache : rawTradeStore.values()) { cache.clear(); } rawTradeStore.clear(); }
java
public void clearOrderDetailsStore() { for (final Map<String, IRippleTradeTransaction> cache : rawTradeStore.values()) { cache.clear(); } rawTradeStore.clear(); }
[ "public", "void", "clearOrderDetailsStore", "(", ")", "{", "for", "(", "final", "Map", "<", "String", ",", "IRippleTradeTransaction", ">", "cache", ":", "rawTradeStore", ".", "values", "(", ")", ")", "{", "cache", ".", "clear", "(", ")", ";", "}", "rawTradeStore", ".", "clear", "(", ")", ";", "}" ]
Clear any stored order details to allow memory to be released.
[ "Clear", "any", "stored", "order", "details", "to", "allow", "memory", "to", "be", "released", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-ripple/src/main/java/org/knowm/xchange/ripple/service/RippleTradeServiceRaw.java#L406-L411
15,730
knowm/XChange
xchange-core/src/main/java/org/knowm/xchange/utils/retries/Retries.java
Retries.callWithRetries
public static <V> V callWithRetries( int nAttempts, int initialRetrySec, Callable<V> action, IPredicate<Exception> retryableException) throws Exception { int retryDelaySec = initialRetrySec; for (int attemptsLeftAfterThis = nAttempts - 1; attemptsLeftAfterThis >= 0; attemptsLeftAfterThis--) { try { return action.call(); } catch (Exception e) { if (!retryableException.test(e)) { throw e; } if (attemptsLeftAfterThis <= 0) { throw new RuntimeException("Ultimately failed after " + nAttempts + " attempts.", e); } log.warn("Failed; {} attempts left: {}", e.toString(), attemptsLeftAfterThis); } retryDelaySec = pauseAndIncrease(retryDelaySec); } throw new RuntimeException("Failed; total attempts allowed: " + nAttempts); }
java
public static <V> V callWithRetries( int nAttempts, int initialRetrySec, Callable<V> action, IPredicate<Exception> retryableException) throws Exception { int retryDelaySec = initialRetrySec; for (int attemptsLeftAfterThis = nAttempts - 1; attemptsLeftAfterThis >= 0; attemptsLeftAfterThis--) { try { return action.call(); } catch (Exception e) { if (!retryableException.test(e)) { throw e; } if (attemptsLeftAfterThis <= 0) { throw new RuntimeException("Ultimately failed after " + nAttempts + " attempts.", e); } log.warn("Failed; {} attempts left: {}", e.toString(), attemptsLeftAfterThis); } retryDelaySec = pauseAndIncrease(retryDelaySec); } throw new RuntimeException("Failed; total attempts allowed: " + nAttempts); }
[ "public", "static", "<", "V", ">", "V", "callWithRetries", "(", "int", "nAttempts", ",", "int", "initialRetrySec", ",", "Callable", "<", "V", ">", "action", ",", "IPredicate", "<", "Exception", ">", "retryableException", ")", "throws", "Exception", "{", "int", "retryDelaySec", "=", "initialRetrySec", ";", "for", "(", "int", "attemptsLeftAfterThis", "=", "nAttempts", "-", "1", ";", "attemptsLeftAfterThis", ">=", "0", ";", "attemptsLeftAfterThis", "--", ")", "{", "try", "{", "return", "action", ".", "call", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "if", "(", "!", "retryableException", ".", "test", "(", "e", ")", ")", "{", "throw", "e", ";", "}", "if", "(", "attemptsLeftAfterThis", "<=", "0", ")", "{", "throw", "new", "RuntimeException", "(", "\"Ultimately failed after \"", "+", "nAttempts", "+", "\" attempts.\"", ",", "e", ")", ";", "}", "log", ".", "warn", "(", "\"Failed; {} attempts left: {}\"", ",", "e", ".", "toString", "(", ")", ",", "attemptsLeftAfterThis", ")", ";", "}", "retryDelaySec", "=", "pauseAndIncrease", "(", "retryDelaySec", ")", ";", "}", "throw", "new", "RuntimeException", "(", "\"Failed; total attempts allowed: \"", "+", "nAttempts", ")", ";", "}" ]
Allows a client to attempt a call and retry a finite amount of times if the exception thrown is the right kind. The retries back off exponentially. @param nAttempts Number of attempts before giving up @param initialRetrySec Number of seconds to wait before trying again on the first retry. @param action A callable or lambda expression that contains the code that will be tried and retried, if necessary. @param retryableException An instance of {@link org.knowm.xchange.utils.retries.IPredicate} that will be used to check if the exception caught is retryable, which can be any complex criteria that the user defines. @return @throws Exception If the exception isn't retryable, it's immediately thrown again. If it is retryable, then a RunTimeException is thrown after the allowed number of retries is exhausted. @author Matija Mazi and Bryan Hernandez
[ "Allows", "a", "client", "to", "attempt", "a", "call", "and", "retry", "a", "finite", "amount", "of", "times", "if", "the", "exception", "thrown", "is", "the", "right", "kind", ".", "The", "retries", "back", "off", "exponentially", "." ]
e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186
https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-core/src/main/java/org/knowm/xchange/utils/retries/Retries.java#L28-L52
15,731
fabric8io/kubernetes-client
kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesResponseComposer.java
KubernetesResponseComposer.join
private static String join(String sep, Collection<String> collection) { StringBuilder builder = new StringBuilder(); boolean first = true; for (String element : collection) { if (first) { first = false; } else { builder.append(sep); } builder.append(element); } return builder.toString(); }
java
private static String join(String sep, Collection<String> collection) { StringBuilder builder = new StringBuilder(); boolean first = true; for (String element : collection) { if (first) { first = false; } else { builder.append(sep); } builder.append(element); } return builder.toString(); }
[ "private", "static", "String", "join", "(", "String", "sep", ",", "Collection", "<", "String", ">", "collection", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "boolean", "first", "=", "true", ";", "for", "(", "String", "element", ":", "collection", ")", "{", "if", "(", "first", ")", "{", "first", "=", "false", ";", "}", "else", "{", "builder", ".", "append", "(", "sep", ")", ";", "}", "builder", ".", "append", "(", "element", ")", ";", "}", "return", "builder", ".", "toString", "(", ")", ";", "}" ]
This is a reimplementation of Java 8's String.join.
[ "This", "is", "a", "reimplementation", "of", "Java", "8", "s", "String", ".", "join", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesResponseComposer.java#L25-L37
15,732
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ApiVersionUtil.java
ApiVersionUtil.apiVersion
public static <T> String apiVersion(T item, String apiVersion) { if (item instanceof HasMetadata && Utils.isNotNullOrEmpty(((HasMetadata) item).getApiVersion())) { return trimVersion(((HasMetadata) item).getApiVersion()); } else if (apiVersion != null && !apiVersion.isEmpty()) { return trimVersion(apiVersion); } return null; }
java
public static <T> String apiVersion(T item, String apiVersion) { if (item instanceof HasMetadata && Utils.isNotNullOrEmpty(((HasMetadata) item).getApiVersion())) { return trimVersion(((HasMetadata) item).getApiVersion()); } else if (apiVersion != null && !apiVersion.isEmpty()) { return trimVersion(apiVersion); } return null; }
[ "public", "static", "<", "T", ">", "String", "apiVersion", "(", "T", "item", ",", "String", "apiVersion", ")", "{", "if", "(", "item", "instanceof", "HasMetadata", "&&", "Utils", ".", "isNotNullOrEmpty", "(", "(", "(", "HasMetadata", ")", "item", ")", ".", "getApiVersion", "(", ")", ")", ")", "{", "return", "trimVersion", "(", "(", "(", "HasMetadata", ")", "item", ")", ".", "getApiVersion", "(", ")", ")", ";", "}", "else", "if", "(", "apiVersion", "!=", "null", "&&", "!", "apiVersion", ".", "isEmpty", "(", ")", ")", "{", "return", "trimVersion", "(", "apiVersion", ")", ";", "}", "return", "null", ";", "}" ]
Returns the api version falling back to the items apiGroupVersion if not null. @param <T> type of parameter @param item item to be processed @param apiVersion apiVersion string @return returns api version
[ "Returns", "the", "api", "version", "falling", "back", "to", "the", "items", "apiGroupVersion", "if", "not", "null", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ApiVersionUtil.java#L45-L52
15,733
fabric8io/kubernetes-client
openshift-client/src/main/java/io/fabric8/openshift/client/OpenshiftAdapterSupport.java
OpenshiftAdapterSupport.isOpenShift
static boolean isOpenShift(Client client) { URL masterUrl = client.getMasterUrl(); if (IS_OPENSHIFT.containsKey(masterUrl)) { return IS_OPENSHIFT.get(masterUrl); } else { RootPaths rootPaths = client.rootPaths(); if (rootPaths != null) { List<String> paths = rootPaths.getPaths(); if (paths != null) { for (String path : paths) { // lets detect the new API Groups APIs for OpenShift if (path.endsWith(".openshift.io") || path.contains(".openshift.io/")) { USES_OPENSHIFT_APIGROUPS.putIfAbsent(masterUrl, true); IS_OPENSHIFT.putIfAbsent(masterUrl, true); return true; } } for (String path : paths) { if (java.util.Objects.equals("/oapi", path) || java.util.Objects.equals("oapi", path)) { IS_OPENSHIFT.putIfAbsent(masterUrl, true); return true; } } } } } IS_OPENSHIFT.putIfAbsent(masterUrl, false); return false; }
java
static boolean isOpenShift(Client client) { URL masterUrl = client.getMasterUrl(); if (IS_OPENSHIFT.containsKey(masterUrl)) { return IS_OPENSHIFT.get(masterUrl); } else { RootPaths rootPaths = client.rootPaths(); if (rootPaths != null) { List<String> paths = rootPaths.getPaths(); if (paths != null) { for (String path : paths) { // lets detect the new API Groups APIs for OpenShift if (path.endsWith(".openshift.io") || path.contains(".openshift.io/")) { USES_OPENSHIFT_APIGROUPS.putIfAbsent(masterUrl, true); IS_OPENSHIFT.putIfAbsent(masterUrl, true); return true; } } for (String path : paths) { if (java.util.Objects.equals("/oapi", path) || java.util.Objects.equals("oapi", path)) { IS_OPENSHIFT.putIfAbsent(masterUrl, true); return true; } } } } } IS_OPENSHIFT.putIfAbsent(masterUrl, false); return false; }
[ "static", "boolean", "isOpenShift", "(", "Client", "client", ")", "{", "URL", "masterUrl", "=", "client", ".", "getMasterUrl", "(", ")", ";", "if", "(", "IS_OPENSHIFT", ".", "containsKey", "(", "masterUrl", ")", ")", "{", "return", "IS_OPENSHIFT", ".", "get", "(", "masterUrl", ")", ";", "}", "else", "{", "RootPaths", "rootPaths", "=", "client", ".", "rootPaths", "(", ")", ";", "if", "(", "rootPaths", "!=", "null", ")", "{", "List", "<", "String", ">", "paths", "=", "rootPaths", ".", "getPaths", "(", ")", ";", "if", "(", "paths", "!=", "null", ")", "{", "for", "(", "String", "path", ":", "paths", ")", "{", "// lets detect the new API Groups APIs for OpenShift", "if", "(", "path", ".", "endsWith", "(", "\".openshift.io\"", ")", "||", "path", ".", "contains", "(", "\".openshift.io/\"", ")", ")", "{", "USES_OPENSHIFT_APIGROUPS", ".", "putIfAbsent", "(", "masterUrl", ",", "true", ")", ";", "IS_OPENSHIFT", ".", "putIfAbsent", "(", "masterUrl", ",", "true", ")", ";", "return", "true", ";", "}", "}", "for", "(", "String", "path", ":", "paths", ")", "{", "if", "(", "java", ".", "util", ".", "Objects", ".", "equals", "(", "\"/oapi\"", ",", "path", ")", "||", "java", ".", "util", ".", "Objects", ".", "equals", "(", "\"oapi\"", ",", "path", ")", ")", "{", "IS_OPENSHIFT", ".", "putIfAbsent", "(", "masterUrl", ",", "true", ")", ";", "return", "true", ";", "}", "}", "}", "}", "}", "IS_OPENSHIFT", ".", "putIfAbsent", "(", "masterUrl", ",", "false", ")", ";", "return", "false", ";", "}" ]
Check if OpenShift is available. @param client The client. @return True if oapi is found in the root paths.
[ "Check", "if", "OpenShift", "is", "available", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/openshift-client/src/main/java/io/fabric8/openshift/client/OpenshiftAdapterSupport.java#L48-L76
15,734
fabric8io/kubernetes-client
openshift-client/src/main/java/io/fabric8/openshift/client/OpenshiftAdapterSupport.java
OpenshiftAdapterSupport.isOpenShiftAPIGroups
static boolean isOpenShiftAPIGroups(Client client) { Config configuration = client.getConfiguration(); if (configuration instanceof OpenShiftConfig) { OpenShiftConfig openShiftConfig = (OpenShiftConfig) configuration; if (openShiftConfig.isDisableApiGroupCheck()) { return false; } } URL masterUrl = client.getMasterUrl(); if (isOpenShift(client) && USES_OPENSHIFT_APIGROUPS.containsKey(masterUrl)) { return USES_OPENSHIFT_APIGROUPS.get(masterUrl); } return false; }
java
static boolean isOpenShiftAPIGroups(Client client) { Config configuration = client.getConfiguration(); if (configuration instanceof OpenShiftConfig) { OpenShiftConfig openShiftConfig = (OpenShiftConfig) configuration; if (openShiftConfig.isDisableApiGroupCheck()) { return false; } } URL masterUrl = client.getMasterUrl(); if (isOpenShift(client) && USES_OPENSHIFT_APIGROUPS.containsKey(masterUrl)) { return USES_OPENSHIFT_APIGROUPS.get(masterUrl); } return false; }
[ "static", "boolean", "isOpenShiftAPIGroups", "(", "Client", "client", ")", "{", "Config", "configuration", "=", "client", ".", "getConfiguration", "(", ")", ";", "if", "(", "configuration", "instanceof", "OpenShiftConfig", ")", "{", "OpenShiftConfig", "openShiftConfig", "=", "(", "OpenShiftConfig", ")", "configuration", ";", "if", "(", "openShiftConfig", ".", "isDisableApiGroupCheck", "(", ")", ")", "{", "return", "false", ";", "}", "}", "URL", "masterUrl", "=", "client", ".", "getMasterUrl", "(", ")", ";", "if", "(", "isOpenShift", "(", "client", ")", "&&", "USES_OPENSHIFT_APIGROUPS", ".", "containsKey", "(", "masterUrl", ")", ")", "{", "return", "USES_OPENSHIFT_APIGROUPS", ".", "get", "(", "masterUrl", ")", ";", "}", "return", "false", ";", "}" ]
Check if OpenShift API Groups are available @param client The client. @return True if the new <code>/apis/*.openshift.io/</code> APIs are found in the root paths.
[ "Check", "if", "OpenShift", "API", "Groups", "are", "available" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/openshift-client/src/main/java/io/fabric8/openshift/client/OpenshiftAdapterSupport.java#L83-L96
15,735
fabric8io/kubernetes-client
openshift-client/src/main/java/io/fabric8/openshift/client/OpenshiftAdapterSupport.java
OpenshiftAdapterSupport.hasCustomOpenShiftUrl
static boolean hasCustomOpenShiftUrl(OpenShiftConfig config) { try { URI masterUri = new URI(config.getMasterUrl()).resolve("/"); URI openshfitUri = new URI(config.getOpenShiftUrl()).resolve("/"); return !masterUri.equals(openshfitUri); } catch (Exception e) { throw KubernetesClientException.launderThrowable(e); } }
java
static boolean hasCustomOpenShiftUrl(OpenShiftConfig config) { try { URI masterUri = new URI(config.getMasterUrl()).resolve("/"); URI openshfitUri = new URI(config.getOpenShiftUrl()).resolve("/"); return !masterUri.equals(openshfitUri); } catch (Exception e) { throw KubernetesClientException.launderThrowable(e); } }
[ "static", "boolean", "hasCustomOpenShiftUrl", "(", "OpenShiftConfig", "config", ")", "{", "try", "{", "URI", "masterUri", "=", "new", "URI", "(", "config", ".", "getMasterUrl", "(", ")", ")", ".", "resolve", "(", "\"/\"", ")", ";", "URI", "openshfitUri", "=", "new", "URI", "(", "config", ".", "getOpenShiftUrl", "(", ")", ")", ".", "resolve", "(", "\"/\"", ")", ";", "return", "!", "masterUri", ".", "equals", "(", "openshfitUri", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "KubernetesClientException", ".", "launderThrowable", "(", "e", ")", ";", "}", "}" ]
Checks if a custom URL for OpenShift has been used. @param config The openshift configuration. @return True if both master and openshift url have the same root.
[ "Checks", "if", "a", "custom", "URL", "for", "OpenShift", "has", "been", "used", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/openshift-client/src/main/java/io/fabric8/openshift/client/OpenshiftAdapterSupport.java#L104-L112
15,736
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/KubernetesClientTimeoutException.java
KubernetesClientTimeoutException.notReadyToString
private static String notReadyToString(Iterable<HasMetadata> resources) { StringBuilder sb = new StringBuilder(); sb.append("Resources that are not ready: "); boolean first = true; for (HasMetadata r : resources) { if (first) { first = false; } else { sb.append(", "); } sb.append("[Kind:").append(r.getKind()) .append(" Name:").append(r.getMetadata().getName()) .append(" Namespace:").append(r.getMetadata().getNamespace()) .append("]"); } return sb.toString(); }
java
private static String notReadyToString(Iterable<HasMetadata> resources) { StringBuilder sb = new StringBuilder(); sb.append("Resources that are not ready: "); boolean first = true; for (HasMetadata r : resources) { if (first) { first = false; } else { sb.append(", "); } sb.append("[Kind:").append(r.getKind()) .append(" Name:").append(r.getMetadata().getName()) .append(" Namespace:").append(r.getMetadata().getNamespace()) .append("]"); } return sb.toString(); }
[ "private", "static", "String", "notReadyToString", "(", "Iterable", "<", "HasMetadata", ">", "resources", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"Resources that are not ready: \"", ")", ";", "boolean", "first", "=", "true", ";", "for", "(", "HasMetadata", "r", ":", "resources", ")", "{", "if", "(", "first", ")", "{", "first", "=", "false", ";", "}", "else", "{", "sb", ".", "append", "(", "\", \"", ")", ";", "}", "sb", ".", "append", "(", "\"[Kind:\"", ")", ".", "append", "(", "r", ".", "getKind", "(", ")", ")", ".", "append", "(", "\" Name:\"", ")", ".", "append", "(", "r", ".", "getMetadata", "(", ")", ".", "getName", "(", ")", ")", ".", "append", "(", "\" Namespace:\"", ")", ".", "append", "(", "r", ".", "getMetadata", "(", ")", ".", "getNamespace", "(", ")", ")", ".", "append", "(", "\"]\"", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Creates a string listing all the resources that are not ready. @param resources The resources that are not ready. @return
[ "Creates", "a", "string", "listing", "all", "the", "resources", "that", "are", "not", "ready", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/KubernetesClientTimeoutException.java#L53-L69
15,737
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/Serialization.java
Serialization.unmarshal
public static <T> T unmarshal(InputStream is, ObjectMapper mapper) { return unmarshal(is, mapper, Collections.<String, String>emptyMap()); }
java
public static <T> T unmarshal(InputStream is, ObjectMapper mapper) { return unmarshal(is, mapper, Collections.<String, String>emptyMap()); }
[ "public", "static", "<", "T", ">", "T", "unmarshal", "(", "InputStream", "is", ",", "ObjectMapper", "mapper", ")", "{", "return", "unmarshal", "(", "is", ",", "mapper", ",", "Collections", ".", "<", "String", ",", "String", ">", "emptyMap", "(", ")", ")", ";", "}" ]
Unmarshals a stream. @param is The {@link InputStream}. @param mapper The {@link ObjectMapper} to use. @param <T> The target type. @return returns de-serialized object @throws KubernetesClientException KubernetesClientException
[ "Unmarshals", "a", "stream", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/Serialization.java#L106-L108
15,738
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RollableScalableResourceOperation.java
RollableScalableResourceOperation.waitUntilScaled
private void waitUntilScaled(final int count) { final ArrayBlockingQueue<Object> queue = new ArrayBlockingQueue<>(1); final AtomicReference<Integer> replicasRef = new AtomicReference<>(0); final String name = checkName(getItem()); final String namespace = checkNamespace(getItem()); final Runnable tPoller = () -> { try { T t = get(); //If the resource is gone, we shouldn't wait. if (t == null) { if (count == 0) { queue.put(true); } else { queue.put(new IllegalStateException("Can't wait for " + getType().getSimpleName() + ": " +name + " in namespace: " + namespace + " to scale. Resource is no longer available.")); } return; } int currentReplicas = getCurrentReplicas(t); int desiredReplicas = getDesiredReplicas(t); replicasRef.set(currentReplicas); long generation = t.getMetadata().getGeneration() != null ? t.getMetadata().getGeneration() : -1; long observedGeneration = getObservedGeneration(t); if (observedGeneration >= generation && Objects.equals(desiredReplicas, currentReplicas)) { queue.put(true); } Log.debug("Only {}/{} replicas scheduled for {}: {} in namespace: {} seconds so waiting...", currentReplicas, desiredReplicas, t.getKind(), t.getMetadata().getName(), namespace); } catch (Throwable t) { Log.error("Error while waiting for resource to be scaled.", t); } }; ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); ScheduledFuture poller = executor.scheduleWithFixedDelay(tPoller, 0, POLL_INTERVAL_MS, TimeUnit.MILLISECONDS); try { if (Utils.waitUntilReady(queue, rollingTimeout, rollingTimeUnit)) { Log.debug("{}/{} pod(s) ready for {}: {} in namespace: {}.", replicasRef.get(), count, getType().getSimpleName(), name, namespace); } else { Log.error("{}/{} pod(s) ready for {}: {} in namespace: {} after waiting for {} seconds so giving up", replicasRef.get(), count, getType().getSimpleName(), name, namespace, rollingTimeUnit.toSeconds(rollingTimeout)); } } finally { poller.cancel(true); executor.shutdown(); } }
java
private void waitUntilScaled(final int count) { final ArrayBlockingQueue<Object> queue = new ArrayBlockingQueue<>(1); final AtomicReference<Integer> replicasRef = new AtomicReference<>(0); final String name = checkName(getItem()); final String namespace = checkNamespace(getItem()); final Runnable tPoller = () -> { try { T t = get(); //If the resource is gone, we shouldn't wait. if (t == null) { if (count == 0) { queue.put(true); } else { queue.put(new IllegalStateException("Can't wait for " + getType().getSimpleName() + ": " +name + " in namespace: " + namespace + " to scale. Resource is no longer available.")); } return; } int currentReplicas = getCurrentReplicas(t); int desiredReplicas = getDesiredReplicas(t); replicasRef.set(currentReplicas); long generation = t.getMetadata().getGeneration() != null ? t.getMetadata().getGeneration() : -1; long observedGeneration = getObservedGeneration(t); if (observedGeneration >= generation && Objects.equals(desiredReplicas, currentReplicas)) { queue.put(true); } Log.debug("Only {}/{} replicas scheduled for {}: {} in namespace: {} seconds so waiting...", currentReplicas, desiredReplicas, t.getKind(), t.getMetadata().getName(), namespace); } catch (Throwable t) { Log.error("Error while waiting for resource to be scaled.", t); } }; ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); ScheduledFuture poller = executor.scheduleWithFixedDelay(tPoller, 0, POLL_INTERVAL_MS, TimeUnit.MILLISECONDS); try { if (Utils.waitUntilReady(queue, rollingTimeout, rollingTimeUnit)) { Log.debug("{}/{} pod(s) ready for {}: {} in namespace: {}.", replicasRef.get(), count, getType().getSimpleName(), name, namespace); } else { Log.error("{}/{} pod(s) ready for {}: {} in namespace: {} after waiting for {} seconds so giving up", replicasRef.get(), count, getType().getSimpleName(), name, namespace, rollingTimeUnit.toSeconds(rollingTimeout)); } } finally { poller.cancel(true); executor.shutdown(); } }
[ "private", "void", "waitUntilScaled", "(", "final", "int", "count", ")", "{", "final", "ArrayBlockingQueue", "<", "Object", ">", "queue", "=", "new", "ArrayBlockingQueue", "<>", "(", "1", ")", ";", "final", "AtomicReference", "<", "Integer", ">", "replicasRef", "=", "new", "AtomicReference", "<>", "(", "0", ")", ";", "final", "String", "name", "=", "checkName", "(", "getItem", "(", ")", ")", ";", "final", "String", "namespace", "=", "checkNamespace", "(", "getItem", "(", ")", ")", ";", "final", "Runnable", "tPoller", "=", "(", ")", "->", "{", "try", "{", "T", "t", "=", "get", "(", ")", ";", "//If the resource is gone, we shouldn't wait.", "if", "(", "t", "==", "null", ")", "{", "if", "(", "count", "==", "0", ")", "{", "queue", ".", "put", "(", "true", ")", ";", "}", "else", "{", "queue", ".", "put", "(", "new", "IllegalStateException", "(", "\"Can't wait for \"", "+", "getType", "(", ")", ".", "getSimpleName", "(", ")", "+", "\": \"", "+", "name", "+", "\" in namespace: \"", "+", "namespace", "+", "\" to scale. Resource is no longer available.\"", ")", ")", ";", "}", "return", ";", "}", "int", "currentReplicas", "=", "getCurrentReplicas", "(", "t", ")", ";", "int", "desiredReplicas", "=", "getDesiredReplicas", "(", "t", ")", ";", "replicasRef", ".", "set", "(", "currentReplicas", ")", ";", "long", "generation", "=", "t", ".", "getMetadata", "(", ")", ".", "getGeneration", "(", ")", "!=", "null", "?", "t", ".", "getMetadata", "(", ")", ".", "getGeneration", "(", ")", ":", "-", "1", ";", "long", "observedGeneration", "=", "getObservedGeneration", "(", "t", ")", ";", "if", "(", "observedGeneration", ">=", "generation", "&&", "Objects", ".", "equals", "(", "desiredReplicas", ",", "currentReplicas", ")", ")", "{", "queue", ".", "put", "(", "true", ")", ";", "}", "Log", ".", "debug", "(", "\"Only {}/{} replicas scheduled for {}: {} in namespace: {} seconds so waiting...\"", ",", "currentReplicas", ",", "desiredReplicas", ",", "t", ".", "getKind", "(", ")", ",", "t", ".", "getMetadata", "(", ")", ".", "getName", "(", ")", ",", "namespace", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "Log", ".", "error", "(", "\"Error while waiting for resource to be scaled.\"", ",", "t", ")", ";", "}", "}", ";", "ScheduledExecutorService", "executor", "=", "Executors", ".", "newSingleThreadScheduledExecutor", "(", ")", ";", "ScheduledFuture", "poller", "=", "executor", ".", "scheduleWithFixedDelay", "(", "tPoller", ",", "0", ",", "POLL_INTERVAL_MS", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "try", "{", "if", "(", "Utils", ".", "waitUntilReady", "(", "queue", ",", "rollingTimeout", ",", "rollingTimeUnit", ")", ")", "{", "Log", ".", "debug", "(", "\"{}/{} pod(s) ready for {}: {} in namespace: {}.\"", ",", "replicasRef", ".", "get", "(", ")", ",", "count", ",", "getType", "(", ")", ".", "getSimpleName", "(", ")", ",", "name", ",", "namespace", ")", ";", "}", "else", "{", "Log", ".", "error", "(", "\"{}/{} pod(s) ready for {}: {} in namespace: {} after waiting for {} seconds so giving up\"", ",", "replicasRef", ".", "get", "(", ")", ",", "count", ",", "getType", "(", ")", ".", "getSimpleName", "(", ")", ",", "name", ",", "namespace", ",", "rollingTimeUnit", ".", "toSeconds", "(", "rollingTimeout", ")", ")", ";", "}", "}", "finally", "{", "poller", ".", "cancel", "(", "true", ")", ";", "executor", ".", "shutdown", "(", ")", ";", "}", "}" ]
Let's wait until there are enough Ready pods.
[ "Let", "s", "wait", "until", "there", "are", "enough", "Ready", "pods", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RollableScalableResourceOperation.java#L85-L133
15,739
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RollingUpdater.java
RollingUpdater.waitUntilPodsAreReady
private void waitUntilPodsAreReady(final T obj, final String namespace, final int requiredPodCount) { final CountDownLatch countDownLatch = new CountDownLatch(1); final AtomicInteger podCount = new AtomicInteger(0); final Runnable readyPodsPoller = () -> { PodList podList = listSelectedPods(obj); int count = 0; List<Pod> items = podList.getItems(); for (Pod item : items) { for (PodCondition c : item.getStatus().getConditions()) { if (c.getType().equals("Ready") && c.getStatus().equals("True")) { count++; } } } podCount.set(count); if (count == requiredPodCount) { countDownLatch.countDown(); } }; ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); ScheduledFuture poller = executor.scheduleWithFixedDelay(readyPodsPoller, 0, 1, TimeUnit.SECONDS); ScheduledFuture logger = executor.scheduleWithFixedDelay(() -> LOG.debug("Only {}/{} pod(s) ready for {}: {} in namespace: {} seconds so waiting...", podCount.get(), requiredPodCount, obj.getKind(), obj.getMetadata().getName(), namespace), 0, loggingIntervalMillis, TimeUnit.MILLISECONDS); try { countDownLatch.await(rollingTimeoutMillis, TimeUnit.MILLISECONDS); executor.shutdown(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); poller.cancel(true); logger.cancel(true); executor.shutdown(); LOG.warn("Only {}/{} pod(s) ready for {}: {} in namespace: {} after waiting for {} seconds so giving up", podCount.get(), requiredPodCount, obj.getKind(), obj.getMetadata().getName(), namespace, TimeUnit.MILLISECONDS.toSeconds(rollingTimeoutMillis)); } }
java
private void waitUntilPodsAreReady(final T obj, final String namespace, final int requiredPodCount) { final CountDownLatch countDownLatch = new CountDownLatch(1); final AtomicInteger podCount = new AtomicInteger(0); final Runnable readyPodsPoller = () -> { PodList podList = listSelectedPods(obj); int count = 0; List<Pod> items = podList.getItems(); for (Pod item : items) { for (PodCondition c : item.getStatus().getConditions()) { if (c.getType().equals("Ready") && c.getStatus().equals("True")) { count++; } } } podCount.set(count); if (count == requiredPodCount) { countDownLatch.countDown(); } }; ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); ScheduledFuture poller = executor.scheduleWithFixedDelay(readyPodsPoller, 0, 1, TimeUnit.SECONDS); ScheduledFuture logger = executor.scheduleWithFixedDelay(() -> LOG.debug("Only {}/{} pod(s) ready for {}: {} in namespace: {} seconds so waiting...", podCount.get(), requiredPodCount, obj.getKind(), obj.getMetadata().getName(), namespace), 0, loggingIntervalMillis, TimeUnit.MILLISECONDS); try { countDownLatch.await(rollingTimeoutMillis, TimeUnit.MILLISECONDS); executor.shutdown(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); poller.cancel(true); logger.cancel(true); executor.shutdown(); LOG.warn("Only {}/{} pod(s) ready for {}: {} in namespace: {} after waiting for {} seconds so giving up", podCount.get(), requiredPodCount, obj.getKind(), obj.getMetadata().getName(), namespace, TimeUnit.MILLISECONDS.toSeconds(rollingTimeoutMillis)); } }
[ "private", "void", "waitUntilPodsAreReady", "(", "final", "T", "obj", ",", "final", "String", "namespace", ",", "final", "int", "requiredPodCount", ")", "{", "final", "CountDownLatch", "countDownLatch", "=", "new", "CountDownLatch", "(", "1", ")", ";", "final", "AtomicInteger", "podCount", "=", "new", "AtomicInteger", "(", "0", ")", ";", "final", "Runnable", "readyPodsPoller", "=", "(", ")", "->", "{", "PodList", "podList", "=", "listSelectedPods", "(", "obj", ")", ";", "int", "count", "=", "0", ";", "List", "<", "Pod", ">", "items", "=", "podList", ".", "getItems", "(", ")", ";", "for", "(", "Pod", "item", ":", "items", ")", "{", "for", "(", "PodCondition", "c", ":", "item", ".", "getStatus", "(", ")", ".", "getConditions", "(", ")", ")", "{", "if", "(", "c", ".", "getType", "(", ")", ".", "equals", "(", "\"Ready\"", ")", "&&", "c", ".", "getStatus", "(", ")", ".", "equals", "(", "\"True\"", ")", ")", "{", "count", "++", ";", "}", "}", "}", "podCount", ".", "set", "(", "count", ")", ";", "if", "(", "count", "==", "requiredPodCount", ")", "{", "countDownLatch", ".", "countDown", "(", ")", ";", "}", "}", ";", "ScheduledExecutorService", "executor", "=", "Executors", ".", "newSingleThreadScheduledExecutor", "(", ")", ";", "ScheduledFuture", "poller", "=", "executor", ".", "scheduleWithFixedDelay", "(", "readyPodsPoller", ",", "0", ",", "1", ",", "TimeUnit", ".", "SECONDS", ")", ";", "ScheduledFuture", "logger", "=", "executor", ".", "scheduleWithFixedDelay", "(", "(", ")", "->", "LOG", ".", "debug", "(", "\"Only {}/{} pod(s) ready for {}: {} in namespace: {} seconds so waiting...\"", ",", "podCount", ".", "get", "(", ")", ",", "requiredPodCount", ",", "obj", ".", "getKind", "(", ")", ",", "obj", ".", "getMetadata", "(", ")", ".", "getName", "(", ")", ",", "namespace", ")", ",", "0", ",", "loggingIntervalMillis", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "try", "{", "countDownLatch", ".", "await", "(", "rollingTimeoutMillis", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "executor", ".", "shutdown", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "Thread", ".", "currentThread", "(", ")", ".", "interrupt", "(", ")", ";", "poller", ".", "cancel", "(", "true", ")", ";", "logger", ".", "cancel", "(", "true", ")", ";", "executor", ".", "shutdown", "(", ")", ";", "LOG", ".", "warn", "(", "\"Only {}/{} pod(s) ready for {}: {} in namespace: {} after waiting for {} seconds so giving up\"", ",", "podCount", ".", "get", "(", ")", ",", "requiredPodCount", ",", "obj", ".", "getKind", "(", ")", ",", "obj", ".", "getMetadata", "(", ")", ".", "getName", "(", ")", ",", "namespace", ",", "TimeUnit", ".", "MILLISECONDS", ".", "toSeconds", "(", "rollingTimeoutMillis", ")", ")", ";", "}", "}" ]
Lets wait until there are enough Ready pods of the given RC
[ "Lets", "wait", "until", "there", "are", "enough", "Ready", "pods", "of", "the", "given", "RC" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RollingUpdater.java#L176-L212
15,740
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/readiness/Readiness.java
Readiness.getPodReadyCondition
private static PodCondition getPodReadyCondition(Pod pod) { Utils.checkNotNull(pod, "Pod can't be null."); if (pod.getStatus() == null || pod.getStatus().getConditions() == null) { return null; } for (PodCondition condition : pod.getStatus().getConditions()) { if (POD_READY.equals(condition.getType())) { return condition; } } return null; }
java
private static PodCondition getPodReadyCondition(Pod pod) { Utils.checkNotNull(pod, "Pod can't be null."); if (pod.getStatus() == null || pod.getStatus().getConditions() == null) { return null; } for (PodCondition condition : pod.getStatus().getConditions()) { if (POD_READY.equals(condition.getType())) { return condition; } } return null; }
[ "private", "static", "PodCondition", "getPodReadyCondition", "(", "Pod", "pod", ")", "{", "Utils", ".", "checkNotNull", "(", "pod", ",", "\"Pod can't be null.\"", ")", ";", "if", "(", "pod", ".", "getStatus", "(", ")", "==", "null", "||", "pod", ".", "getStatus", "(", ")", ".", "getConditions", "(", ")", "==", "null", ")", "{", "return", "null", ";", "}", "for", "(", "PodCondition", "condition", ":", "pod", ".", "getStatus", "(", ")", ".", "getConditions", "(", ")", ")", "{", "if", "(", "POD_READY", ".", "equals", "(", "condition", ".", "getType", "(", ")", ")", ")", "{", "return", "condition", ";", "}", "}", "return", "null", ";", "}" ]
Returns the ready condition of the pod. @param pod The target pod. @return The {@link PodCondition} or null if not found.
[ "Returns", "the", "ready", "condition", "of", "the", "pod", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/readiness/Readiness.java#L206-L219
15,741
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/readiness/Readiness.java
Readiness.getNodeReadyCondition
private static NodeCondition getNodeReadyCondition(Node node) { Utils.checkNotNull(node, "Node can't be null."); if (node.getStatus() == null || node.getStatus().getConditions() == null) { return null; } for (NodeCondition condition : node.getStatus().getConditions()) { if (NODE_READY.equals(condition.getType())) { return condition; } } return null; }
java
private static NodeCondition getNodeReadyCondition(Node node) { Utils.checkNotNull(node, "Node can't be null."); if (node.getStatus() == null || node.getStatus().getConditions() == null) { return null; } for (NodeCondition condition : node.getStatus().getConditions()) { if (NODE_READY.equals(condition.getType())) { return condition; } } return null; }
[ "private", "static", "NodeCondition", "getNodeReadyCondition", "(", "Node", "node", ")", "{", "Utils", ".", "checkNotNull", "(", "node", ",", "\"Node can't be null.\"", ")", ";", "if", "(", "node", ".", "getStatus", "(", ")", "==", "null", "||", "node", ".", "getStatus", "(", ")", ".", "getConditions", "(", ")", "==", "null", ")", "{", "return", "null", ";", "}", "for", "(", "NodeCondition", "condition", ":", "node", ".", "getStatus", "(", ")", ".", "getConditions", "(", ")", ")", "{", "if", "(", "NODE_READY", ".", "equals", "(", "condition", ".", "getType", "(", ")", ")", ")", "{", "return", "condition", ";", "}", "}", "return", "null", ";", "}" ]
Returns the ready condition of the node. @param node The target node. @return The {@link NodeCondition} or null if not found.
[ "Returns", "the", "ready", "condition", "of", "the", "node", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/readiness/Readiness.java#L236-L249
15,742
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java
KubernetesResourceUtil.getResourceVersion
public static String getResourceVersion(HasMetadata entity) { if (entity != null) { ObjectMeta metadata = entity.getMetadata(); if (metadata != null) { String resourceVersion = metadata.getResourceVersion(); if (!Utils.isNullOrEmpty(resourceVersion)) { return resourceVersion; } } } return null; }
java
public static String getResourceVersion(HasMetadata entity) { if (entity != null) { ObjectMeta metadata = entity.getMetadata(); if (metadata != null) { String resourceVersion = metadata.getResourceVersion(); if (!Utils.isNullOrEmpty(resourceVersion)) { return resourceVersion; } } } return null; }
[ "public", "static", "String", "getResourceVersion", "(", "HasMetadata", "entity", ")", "{", "if", "(", "entity", "!=", "null", ")", "{", "ObjectMeta", "metadata", "=", "entity", ".", "getMetadata", "(", ")", ";", "if", "(", "metadata", "!=", "null", ")", "{", "String", "resourceVersion", "=", "metadata", ".", "getResourceVersion", "(", ")", ";", "if", "(", "!", "Utils", ".", "isNullOrEmpty", "(", "resourceVersion", ")", ")", "{", "return", "resourceVersion", ";", "}", "}", "}", "return", "null", ";", "}" ]
Returns the resource version for the entity or null if it does not have one @param entity entity provided @return returns resource version of provided entity
[ "Returns", "the", "resource", "version", "for", "the", "entity", "or", "null", "if", "it", "does", "not", "have", "one" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java#L40-L51
15,743
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java
KubernetesResourceUtil.getKind
public static String getKind(HasMetadata entity) { if (entity != null) { // TODO use reflection to find the kind? if (entity instanceof KubernetesList) { return "List"; } else { return entity.getClass().getSimpleName(); } } else { return null; } }
java
public static String getKind(HasMetadata entity) { if (entity != null) { // TODO use reflection to find the kind? if (entity instanceof KubernetesList) { return "List"; } else { return entity.getClass().getSimpleName(); } } else { return null; } }
[ "public", "static", "String", "getKind", "(", "HasMetadata", "entity", ")", "{", "if", "(", "entity", "!=", "null", ")", "{", "// TODO use reflection to find the kind?", "if", "(", "entity", "instanceof", "KubernetesList", ")", "{", "return", "\"List\"", ";", "}", "else", "{", "return", "entity", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ";", "}", "}", "else", "{", "return", "null", ";", "}", "}" ]
Returns the kind of the entity @param entity provided entity @return returns kind of entity provided
[ "Returns", "the", "kind", "of", "the", "entity" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java#L59-L70
15,744
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java
KubernetesResourceUtil.getQualifiedName
public static String getQualifiedName(HasMetadata entity) { if (entity != null) { return "" + getNamespace(entity) + "/" + getName(entity); } else { return null; } }
java
public static String getQualifiedName(HasMetadata entity) { if (entity != null) { return "" + getNamespace(entity) + "/" + getName(entity); } else { return null; } }
[ "public", "static", "String", "getQualifiedName", "(", "HasMetadata", "entity", ")", "{", "if", "(", "entity", "!=", "null", ")", "{", "return", "\"\"", "+", "getNamespace", "(", "entity", ")", "+", "\"/\"", "+", "getName", "(", "entity", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Returns Qualified name for the specified Kubernetes Resource @param entity Kubernetes resource @return returns qualified name
[ "Returns", "Qualified", "name", "for", "the", "specified", "Kubernetes", "Resource" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java#L78-L84
15,745
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java
KubernetesResourceUtil.getNamespace
public static String getNamespace(HasMetadata entity) { if (entity != null) { return getNamespace(entity.getMetadata()); } else { return null; } }
java
public static String getNamespace(HasMetadata entity) { if (entity != null) { return getNamespace(entity.getMetadata()); } else { return null; } }
[ "public", "static", "String", "getNamespace", "(", "HasMetadata", "entity", ")", "{", "if", "(", "entity", "!=", "null", ")", "{", "return", "getNamespace", "(", "entity", ".", "getMetadata", "(", ")", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Getting namespace from Kubernetes Resource @param entity Kubernetes Resource @return returns namespace as plain string
[ "Getting", "namespace", "from", "Kubernetes", "Resource" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java#L163-L169
15,746
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java
KubernetesResourceUtil.getOrCreateLabels
public static Map<String, String> getOrCreateLabels(HasMetadata entity) { ObjectMeta metadata = getOrCreateMetadata(entity); Map<String, String> answer = metadata.getLabels(); if (answer == null) { // use linked so the annotations can be in the FIFO order answer = new LinkedHashMap<>(); metadata.setLabels(answer); } return answer; }
java
public static Map<String, String> getOrCreateLabels(HasMetadata entity) { ObjectMeta metadata = getOrCreateMetadata(entity); Map<String, String> answer = metadata.getLabels(); if (answer == null) { // use linked so the annotations can be in the FIFO order answer = new LinkedHashMap<>(); metadata.setLabels(answer); } return answer; }
[ "public", "static", "Map", "<", "String", ",", "String", ">", "getOrCreateLabels", "(", "HasMetadata", "entity", ")", "{", "ObjectMeta", "metadata", "=", "getOrCreateMetadata", "(", "entity", ")", ";", "Map", "<", "String", ",", "String", ">", "answer", "=", "metadata", ".", "getLabels", "(", ")", ";", "if", "(", "answer", "==", "null", ")", "{", "// use linked so the annotations can be in the FIFO order", "answer", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "metadata", ".", "setLabels", "(", "answer", ")", ";", "}", "return", "answer", ";", "}" ]
Null safe get method for getting Labels of a Kubernetes Resource @param entity Kubernetes Resource @return returns a hashmap containing labels
[ "Null", "safe", "get", "method", "for", "getting", "Labels", "of", "a", "Kubernetes", "Resource" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java#L207-L216
15,747
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java
KubernetesResourceUtil.getLabels
@SuppressWarnings("unchecked") public static Map<String, String> getLabels(ObjectMeta metadata) { if (metadata != null) { Map<String, String> labels = metadata.getLabels(); if (labels != null) { return labels; } } return Collections.EMPTY_MAP; }
java
@SuppressWarnings("unchecked") public static Map<String, String> getLabels(ObjectMeta metadata) { if (metadata != null) { Map<String, String> labels = metadata.getLabels(); if (labels != null) { return labels; } } return Collections.EMPTY_MAP; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "Map", "<", "String", ",", "String", ">", "getLabels", "(", "ObjectMeta", "metadata", ")", "{", "if", "(", "metadata", "!=", "null", ")", "{", "Map", "<", "String", ",", "String", ">", "labels", "=", "metadata", ".", "getLabels", "(", ")", ";", "if", "(", "labels", "!=", "null", ")", "{", "return", "labels", ";", "}", "}", "return", "Collections", ".", "EMPTY_MAP", ";", "}" ]
Returns the labels of the given metadata object or an empty map if the metadata or labels are null @param metadata ObjectMeta for resource's metadata @return returns labels as a hashmap
[ "Returns", "the", "labels", "of", "the", "given", "metadata", "object", "or", "an", "empty", "map", "if", "the", "metadata", "or", "labels", "are", "null" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java#L225-L234
15,748
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java
KubernetesResourceUtil.isValidName
public static boolean isValidName(String name) { return Utils.isNotNullOrEmpty(name) && name.length() < KUBERNETES_DNS1123_LABEL_MAX_LENGTH && KUBERNETES_DNS1123_LABEL_REGEX.matcher(name).matches(); }
java
public static boolean isValidName(String name) { return Utils.isNotNullOrEmpty(name) && name.length() < KUBERNETES_DNS1123_LABEL_MAX_LENGTH && KUBERNETES_DNS1123_LABEL_REGEX.matcher(name).matches(); }
[ "public", "static", "boolean", "isValidName", "(", "String", "name", ")", "{", "return", "Utils", ".", "isNotNullOrEmpty", "(", "name", ")", "&&", "name", ".", "length", "(", ")", "<", "KUBERNETES_DNS1123_LABEL_MAX_LENGTH", "&&", "KUBERNETES_DNS1123_LABEL_REGEX", ".", "matcher", "(", "name", ")", ".", "matches", "(", ")", ";", "}" ]
Validates name of Kubernetes Resource name, label or annotation based on Kubernetes regex @param name Name of resource/label/annotation @return returns a boolean value indicating whether it's valid or not
[ "Validates", "name", "of", "Kubernetes", "Resource", "name", "label", "or", "annotation", "based", "on", "Kubernetes", "regex" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java#L257-L261
15,749
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ReplaceValueStream.java
ReplaceValueStream.replaceValues
public static InputStream replaceValues(InputStream is, Map<String, String> valuesMap) { return new ReplaceValueStream(valuesMap).createInputStream(is); }
java
public static InputStream replaceValues(InputStream is, Map<String, String> valuesMap) { return new ReplaceValueStream(valuesMap).createInputStream(is); }
[ "public", "static", "InputStream", "replaceValues", "(", "InputStream", "is", ",", "Map", "<", "String", ",", "String", ">", "valuesMap", ")", "{", "return", "new", "ReplaceValueStream", "(", "valuesMap", ")", ".", "createInputStream", "(", "is", ")", ";", "}" ]
Returns a stream with the template parameter expressions replaced @param is {@link InputStream} inputstream for @param valuesMap a hashmap containing parameters @return returns stream with template parameter expressions replaced
[ "Returns", "a", "stream", "with", "the", "template", "parameter", "expressions", "replaced" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ReplaceValueStream.java#L39-L41
15,750
fabric8io/kubernetes-client
kubernetes-model/kubernetes-model/src/main/java/io/fabric8/kubernetes/internal/KubernetesDeserializer.java
KubernetesDeserializer.getKey
private static final String getKey(String apiVersion, String kind) { if (kind == null) { return null; } else if (apiVersion == null) { return kind; } else { return String.format("%s#%s", apiVersion, kind); } }
java
private static final String getKey(String apiVersion, String kind) { if (kind == null) { return null; } else if (apiVersion == null) { return kind; } else { return String.format("%s#%s", apiVersion, kind); } }
[ "private", "static", "final", "String", "getKey", "(", "String", "apiVersion", ",", "String", "kind", ")", "{", "if", "(", "kind", "==", "null", ")", "{", "return", "null", ";", "}", "else", "if", "(", "apiVersion", "==", "null", ")", "{", "return", "kind", ";", "}", "else", "{", "return", "String", ".", "format", "(", "\"%s#%s\"", ",", "apiVersion", ",", "kind", ")", ";", "}", "}" ]
Returns a composite key for apiVersion and kind.
[ "Returns", "a", "composite", "key", "for", "apiVersion", "and", "kind", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-model/kubernetes-model/src/main/java/io/fabric8/kubernetes/internal/KubernetesDeserializer.java#L100-L108
15,751
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/KubeConfigUtils.java
KubeConfigUtils.getUserToken
public static String getUserToken(Config config, Context context) { AuthInfo authInfo = getUserAuthInfo(config, context); if (authInfo != null) { return authInfo.getToken(); } return null; }
java
public static String getUserToken(Config config, Context context) { AuthInfo authInfo = getUserAuthInfo(config, context); if (authInfo != null) { return authInfo.getToken(); } return null; }
[ "public", "static", "String", "getUserToken", "(", "Config", "config", ",", "Context", "context", ")", "{", "AuthInfo", "authInfo", "=", "getUserAuthInfo", "(", "config", ",", "context", ")", ";", "if", "(", "authInfo", "!=", "null", ")", "{", "return", "authInfo", ".", "getToken", "(", ")", ";", "}", "return", "null", ";", "}" ]
Returns the current user token for the config and current context @param config Config object @param context Context object @return returns current user based upon provided parameters.
[ "Returns", "the", "current", "user", "token", "for", "the", "config", "and", "current", "context" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/KubeConfigUtils.java#L78-L84
15,752
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl.java
NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl.checkConditionMetForAll
private static boolean checkConditionMetForAll(CountDownLatch latch, int expected, AtomicInteger actual, long amount, TimeUnit timeUnit) { try { if (latch.await(amount, timeUnit)) { return actual.intValue() == expected; } return false; } catch (InterruptedException e) { Thread.currentThread().interrupt(); return false; } }
java
private static boolean checkConditionMetForAll(CountDownLatch latch, int expected, AtomicInteger actual, long amount, TimeUnit timeUnit) { try { if (latch.await(amount, timeUnit)) { return actual.intValue() == expected; } return false; } catch (InterruptedException e) { Thread.currentThread().interrupt(); return false; } }
[ "private", "static", "boolean", "checkConditionMetForAll", "(", "CountDownLatch", "latch", ",", "int", "expected", ",", "AtomicInteger", "actual", ",", "long", "amount", ",", "TimeUnit", "timeUnit", ")", "{", "try", "{", "if", "(", "latch", ".", "await", "(", "amount", ",", "timeUnit", ")", ")", "{", "return", "actual", ".", "intValue", "(", ")", "==", "expected", ";", "}", "return", "false", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "Thread", ".", "currentThread", "(", ")", ".", "interrupt", "(", ")", ";", "return", "false", ";", "}", "}" ]
Waits until the latch reaches to zero and then checks if the expected result @param latch The latch. @param expected The expected number. @param actual The actual number. @param amount The amount of time to wait. @param timeUnit The timeUnit. @return
[ "Waits", "until", "the", "latch", "reaches", "to", "zero", "and", "then", "checks", "if", "the", "expected", "result" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl.java#L421-L431
15,753
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/HasMetadataOperation.java
HasMetadataOperation.periodicWatchUntilReady
protected T periodicWatchUntilReady(int i, long started, long interval, long amount) { T item = fromServer().get(); if (Readiness.isReady(item)) { return item; } ReadinessWatcher<T> watcher = new ReadinessWatcher<>(item); try (Watch watch = watch(item.getMetadata().getResourceVersion(), watcher)) { try { return watcher.await(interval, TimeUnit.MILLISECONDS); } catch (KubernetesClientTimeoutException e) { if (i <= 0) { throw e; } } long remaining = (started + amount) - System.nanoTime(); long next = Math.max(0, Math.min(remaining, interval)); return periodicWatchUntilReady(i - 1, started, next, amount); } }
java
protected T periodicWatchUntilReady(int i, long started, long interval, long amount) { T item = fromServer().get(); if (Readiness.isReady(item)) { return item; } ReadinessWatcher<T> watcher = new ReadinessWatcher<>(item); try (Watch watch = watch(item.getMetadata().getResourceVersion(), watcher)) { try { return watcher.await(interval, TimeUnit.MILLISECONDS); } catch (KubernetesClientTimeoutException e) { if (i <= 0) { throw e; } } long remaining = (started + amount) - System.nanoTime(); long next = Math.max(0, Math.min(remaining, interval)); return periodicWatchUntilReady(i - 1, started, next, amount); } }
[ "protected", "T", "periodicWatchUntilReady", "(", "int", "i", ",", "long", "started", ",", "long", "interval", ",", "long", "amount", ")", "{", "T", "item", "=", "fromServer", "(", ")", ".", "get", "(", ")", ";", "if", "(", "Readiness", ".", "isReady", "(", "item", ")", ")", "{", "return", "item", ";", "}", "ReadinessWatcher", "<", "T", ">", "watcher", "=", "new", "ReadinessWatcher", "<>", "(", "item", ")", ";", "try", "(", "Watch", "watch", "=", "watch", "(", "item", ".", "getMetadata", "(", ")", ".", "getResourceVersion", "(", ")", ",", "watcher", ")", ")", "{", "try", "{", "return", "watcher", ".", "await", "(", "interval", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "}", "catch", "(", "KubernetesClientTimeoutException", "e", ")", "{", "if", "(", "i", "<=", "0", ")", "{", "throw", "e", ";", "}", "}", "long", "remaining", "=", "(", "started", "+", "amount", ")", "-", "System", ".", "nanoTime", "(", ")", ";", "long", "next", "=", "Math", ".", "max", "(", "0", ",", "Math", ".", "min", "(", "remaining", ",", "interval", ")", ")", ";", "return", "periodicWatchUntilReady", "(", "i", "-", "1", ",", "started", ",", "next", ",", "amount", ")", ";", "}", "}" ]
A wait method that combines watching and polling. The need for that is that in some cases a pure watcher approach consistently fails. @param i The number of iterations to perform. @param started Time in milliseconds where the watch started. @param interval The amount of time in millis to wait on each iteration. @param amount The maximum amount in millis of time since started to wait. @return The {@link ReplicationController} if ready.
[ "A", "wait", "method", "that", "combines", "watching", "and", "polling", ".", "The", "need", "for", "that", "is", "that", "in", "some", "cases", "a", "pure", "watcher", "approach", "consistently", "fails", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/HasMetadataOperation.java#L183-L203
15,754
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/Utils.java
Utils.replaceAllWithoutRegex
public static String replaceAllWithoutRegex(String text, String from, String to) { if (text == null) { return null; } int idx = 0; while (true) { idx = text.indexOf(from, idx); if (idx >= 0) { text = text.substring(0, idx) + to + text.substring(idx + from.length()); // lets start searching after the end of the `to` to avoid possible infinite recursion idx += to.length(); } else { break; } } return text; }
java
public static String replaceAllWithoutRegex(String text, String from, String to) { if (text == null) { return null; } int idx = 0; while (true) { idx = text.indexOf(from, idx); if (idx >= 0) { text = text.substring(0, idx) + to + text.substring(idx + from.length()); // lets start searching after the end of the `to` to avoid possible infinite recursion idx += to.length(); } else { break; } } return text; }
[ "public", "static", "String", "replaceAllWithoutRegex", "(", "String", "text", ",", "String", "from", ",", "String", "to", ")", "{", "if", "(", "text", "==", "null", ")", "{", "return", "null", ";", "}", "int", "idx", "=", "0", ";", "while", "(", "true", ")", "{", "idx", "=", "text", ".", "indexOf", "(", "from", ",", "idx", ")", ";", "if", "(", "idx", ">=", "0", ")", "{", "text", "=", "text", ".", "substring", "(", "0", ",", "idx", ")", "+", "to", "+", "text", ".", "substring", "(", "idx", "+", "from", ".", "length", "(", ")", ")", ";", "// lets start searching after the end of the `to` to avoid possible infinite recursion", "idx", "+=", "to", ".", "length", "(", ")", ";", "}", "else", "{", "break", ";", "}", "}", "return", "text", ";", "}" ]
Replaces all occurrences of the from text with to text without any regular expressions @param text text string @param from from string @param to to string @return returns processed string
[ "Replaces", "all", "occurrences", "of", "the", "from", "text", "with", "to", "text", "without", "any", "regular", "expressions" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/Utils.java#L260-L277
15,755
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/Utils.java
Utils.toUrlEncoded
public static final String toUrlEncoded(String str) { try { return URLEncoder.encode(str, "UTF-8"); } catch (UnsupportedEncodingException exception) { // Ignore } return null; }
java
public static final String toUrlEncoded(String str) { try { return URLEncoder.encode(str, "UTF-8"); } catch (UnsupportedEncodingException exception) { // Ignore } return null; }
[ "public", "static", "final", "String", "toUrlEncoded", "(", "String", "str", ")", "{", "try", "{", "return", "URLEncoder", ".", "encode", "(", "str", ",", "\"UTF-8\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "exception", ")", "{", "// Ignore", "}", "return", "null", ";", "}" ]
Converts string to URL encoded string. @param str Url as string @return returns encoded string
[ "Converts", "string", "to", "URL", "encoded", "string", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/Utils.java#L314-L321
15,756
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java
BaseOperation.name
private static <T> String name(T item, String name) { if (name != null && !name.isEmpty()) { return name; } else if (item instanceof HasMetadata) { HasMetadata h = (HasMetadata) item; return h.getMetadata() != null ? h.getMetadata().getName() : null; } return null; }
java
private static <T> String name(T item, String name) { if (name != null && !name.isEmpty()) { return name; } else if (item instanceof HasMetadata) { HasMetadata h = (HasMetadata) item; return h.getMetadata() != null ? h.getMetadata().getName() : null; } return null; }
[ "private", "static", "<", "T", ">", "String", "name", "(", "T", "item", ",", "String", "name", ")", "{", "if", "(", "name", "!=", "null", "&&", "!", "name", ".", "isEmpty", "(", ")", ")", "{", "return", "name", ";", "}", "else", "if", "(", "item", "instanceof", "HasMetadata", ")", "{", "HasMetadata", "h", "=", "(", "HasMetadata", ")", "item", ";", "return", "h", ".", "getMetadata", "(", ")", "!=", "null", "?", "h", ".", "getMetadata", "(", ")", ".", "getName", "(", ")", ":", "null", ";", "}", "return", "null", ";", "}" ]
Returns the name and falls back to the item name. @param item The item. @param name The name to check. @param <T> @return
[ "Returns", "the", "name", "and", "falls", "back", "to", "the", "item", "name", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java#L115-L123
15,757
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java
BaseOperation.updateApiVersionResource
protected void updateApiVersionResource(Object resource) { if (resource instanceof HasMetadata) { HasMetadata hasMetadata = (HasMetadata) resource; updateApiVersion(hasMetadata); } else if (resource instanceof KubernetesResourceList) { KubernetesResourceList list = (KubernetesResourceList) resource; updateApiVersion(list); } }
java
protected void updateApiVersionResource(Object resource) { if (resource instanceof HasMetadata) { HasMetadata hasMetadata = (HasMetadata) resource; updateApiVersion(hasMetadata); } else if (resource instanceof KubernetesResourceList) { KubernetesResourceList list = (KubernetesResourceList) resource; updateApiVersion(list); } }
[ "protected", "void", "updateApiVersionResource", "(", "Object", "resource", ")", "{", "if", "(", "resource", "instanceof", "HasMetadata", ")", "{", "HasMetadata", "hasMetadata", "=", "(", "HasMetadata", ")", "resource", ";", "updateApiVersion", "(", "hasMetadata", ")", ";", "}", "else", "if", "(", "resource", "instanceof", "KubernetesResourceList", ")", "{", "KubernetesResourceList", "list", "=", "(", "KubernetesResourceList", ")", "resource", ";", "updateApiVersion", "(", "list", ")", ";", "}", "}" ]
Updates the list or single item if it has a missing or incorrect apiGroupVersion @param resource resource object
[ "Updates", "the", "list", "or", "single", "item", "if", "it", "has", "a", "missing", "or", "incorrect", "apiGroupVersion" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java#L853-L861
15,758
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java
BaseOperation.updateApiVersion
protected void updateApiVersion(KubernetesResourceList list) { String version = getApiVersion(); if (list != null && version != null && version.length() > 0) { List items = list.getItems(); if (items != null) { for (Object item : items) { if (item instanceof HasMetadata) { updateApiVersion((HasMetadata) item); } } } } }
java
protected void updateApiVersion(KubernetesResourceList list) { String version = getApiVersion(); if (list != null && version != null && version.length() > 0) { List items = list.getItems(); if (items != null) { for (Object item : items) { if (item instanceof HasMetadata) { updateApiVersion((HasMetadata) item); } } } } }
[ "protected", "void", "updateApiVersion", "(", "KubernetesResourceList", "list", ")", "{", "String", "version", "=", "getApiVersion", "(", ")", ";", "if", "(", "list", "!=", "null", "&&", "version", "!=", "null", "&&", "version", ".", "length", "(", ")", ">", "0", ")", "{", "List", "items", "=", "list", ".", "getItems", "(", ")", ";", "if", "(", "items", "!=", "null", ")", "{", "for", "(", "Object", "item", ":", "items", ")", "{", "if", "(", "item", "instanceof", "HasMetadata", ")", "{", "updateApiVersion", "(", "(", "HasMetadata", ")", "item", ")", ";", "}", "}", "}", "}", "}" ]
Updates the list items if they have missing or default apiGroupVersion values and the resource is currently using API Groups with custom version strings @param list Kubernetes resource list
[ "Updates", "the", "list", "items", "if", "they", "have", "missing", "or", "default", "apiGroupVersion", "values", "and", "the", "resource", "is", "currently", "using", "API", "Groups", "with", "custom", "version", "strings" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java#L869-L881
15,759
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java
BaseOperation.updateApiVersion
protected void updateApiVersion(HasMetadata hasMetadata) { String version = getApiVersion(); if (hasMetadata != null && version != null && version.length() > 0) { String current = hasMetadata.getApiVersion(); // lets overwrite the api version if its currently missing, the resource uses an API Group with '/' // or we have the default of 'v1' when using an API group version like 'build.openshift.io/v1' if (current == null || "v1".equals(current) || current.indexOf('/') < 0 && version.indexOf('/') > 0) { hasMetadata.setApiVersion(version); } } }
java
protected void updateApiVersion(HasMetadata hasMetadata) { String version = getApiVersion(); if (hasMetadata != null && version != null && version.length() > 0) { String current = hasMetadata.getApiVersion(); // lets overwrite the api version if its currently missing, the resource uses an API Group with '/' // or we have the default of 'v1' when using an API group version like 'build.openshift.io/v1' if (current == null || "v1".equals(current) || current.indexOf('/') < 0 && version.indexOf('/') > 0) { hasMetadata.setApiVersion(version); } } }
[ "protected", "void", "updateApiVersion", "(", "HasMetadata", "hasMetadata", ")", "{", "String", "version", "=", "getApiVersion", "(", ")", ";", "if", "(", "hasMetadata", "!=", "null", "&&", "version", "!=", "null", "&&", "version", ".", "length", "(", ")", ">", "0", ")", "{", "String", "current", "=", "hasMetadata", ".", "getApiVersion", "(", ")", ";", "// lets overwrite the api version if its currently missing, the resource uses an API Group with '/'", "// or we have the default of 'v1' when using an API group version like 'build.openshift.io/v1'", "if", "(", "current", "==", "null", "||", "\"v1\"", ".", "equals", "(", "current", ")", "||", "current", ".", "indexOf", "(", "'", "'", ")", "<", "0", "&&", "version", ".", "indexOf", "(", "'", "'", ")", ">", "0", ")", "{", "hasMetadata", ".", "setApiVersion", "(", "version", ")", ";", "}", "}", "}" ]
Updates the resource if it has missing or default apiGroupVersion values and the resource is currently using API Groups with custom version strings @param hasMetadata object whose api version needs to be updated
[ "Updates", "the", "resource", "if", "it", "has", "missing", "or", "default", "apiGroupVersion", "values", "and", "the", "resource", "is", "currently", "using", "API", "Groups", "with", "custom", "version", "strings" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java#L890-L900
15,760
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java
OperationSupport.handleCreate
protected <T, I> T handleCreate(I resource, Class<T> outputType) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { RequestBody body = RequestBody.create(JSON, JSON_MAPPER.writeValueAsString(resource)); Request.Builder requestBuilder = new Request.Builder().post(body).url(getNamespacedUrl(checkNamespace(resource))); return handleResponse(requestBuilder, outputType, Collections.<String, String>emptyMap()); }
java
protected <T, I> T handleCreate(I resource, Class<T> outputType) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { RequestBody body = RequestBody.create(JSON, JSON_MAPPER.writeValueAsString(resource)); Request.Builder requestBuilder = new Request.Builder().post(body).url(getNamespacedUrl(checkNamespace(resource))); return handleResponse(requestBuilder, outputType, Collections.<String, String>emptyMap()); }
[ "protected", "<", "T", ",", "I", ">", "T", "handleCreate", "(", "I", "resource", ",", "Class", "<", "T", ">", "outputType", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "KubernetesClientException", ",", "IOException", "{", "RequestBody", "body", "=", "RequestBody", ".", "create", "(", "JSON", ",", "JSON_MAPPER", ".", "writeValueAsString", "(", "resource", ")", ")", ";", "Request", ".", "Builder", "requestBuilder", "=", "new", "Request", ".", "Builder", "(", ")", ".", "post", "(", "body", ")", ".", "url", "(", "getNamespacedUrl", "(", "checkNamespace", "(", "resource", ")", ")", ")", ";", "return", "handleResponse", "(", "requestBuilder", ",", "outputType", ",", "Collections", ".", "<", "String", ",", "String", ">", "emptyMap", "(", ")", ")", ";", "}" ]
Create a resource. @param resource resource provided @param outputType resource type you want as output @param <T> template argument for output type @param <I> template argument for resource @return returns de-serialized version of apiserver response in form of type provided @throws ExecutionException Execution Exception @throws InterruptedException Interrupted Exception @throws KubernetesClientException KubernetesClientException @throws IOException IOException
[ "Create", "a", "resource", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java#L231-L235
15,761
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java
OperationSupport.handleReplace
protected <T> T handleReplace(T updated, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { return handleReplace(updated, type, Collections.<String, String>emptyMap()); }
java
protected <T> T handleReplace(T updated, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { return handleReplace(updated, type, Collections.<String, String>emptyMap()); }
[ "protected", "<", "T", ">", "T", "handleReplace", "(", "T", "updated", ",", "Class", "<", "T", ">", "type", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "KubernetesClientException", ",", "IOException", "{", "return", "handleReplace", "(", "updated", ",", "type", ",", "Collections", ".", "<", "String", ",", "String", ">", "emptyMap", "(", ")", ")", ";", "}" ]
Replace a resource. @param updated updated object @param type type of the object provided @param <T> template argument provided @return returns de-serialized version of api server response @throws ExecutionException Execution Exception @throws InterruptedException Interrupted Exception @throws KubernetesClientException KubernetesClientException @throws IOException IOException
[ "Replace", "a", "resource", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java#L251-L253
15,762
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java
OperationSupport.handleReplace
protected <T> T handleReplace(T updated, Class<T> type, Map<String, String> parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { RequestBody body = RequestBody.create(JSON, JSON_MAPPER.writeValueAsString(updated)); Request.Builder requestBuilder = new Request.Builder().put(body).url(getResourceUrl(checkNamespace(updated), checkName(updated))); return handleResponse(requestBuilder, type, parameters); }
java
protected <T> T handleReplace(T updated, Class<T> type, Map<String, String> parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { RequestBody body = RequestBody.create(JSON, JSON_MAPPER.writeValueAsString(updated)); Request.Builder requestBuilder = new Request.Builder().put(body).url(getResourceUrl(checkNamespace(updated), checkName(updated))); return handleResponse(requestBuilder, type, parameters); }
[ "protected", "<", "T", ">", "T", "handleReplace", "(", "T", "updated", ",", "Class", "<", "T", ">", "type", ",", "Map", "<", "String", ",", "String", ">", "parameters", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "KubernetesClientException", ",", "IOException", "{", "RequestBody", "body", "=", "RequestBody", ".", "create", "(", "JSON", ",", "JSON_MAPPER", ".", "writeValueAsString", "(", "updated", ")", ")", ";", "Request", ".", "Builder", "requestBuilder", "=", "new", "Request", ".", "Builder", "(", ")", ".", "put", "(", "body", ")", ".", "url", "(", "getResourceUrl", "(", "checkNamespace", "(", "updated", ")", ",", "checkName", "(", "updated", ")", ")", ")", ";", "return", "handleResponse", "(", "requestBuilder", ",", "type", ",", "parameters", ")", ";", "}" ]
Replace a resource, optionally performing placeholder substitution to the response. @param updated updated object @param type type of object provided @param parameters a HashMap containing parameters for processing object @param <T> template argument provided @return returns de-serialized version of api server response. @throws ExecutionException Execution Exception @throws InterruptedException Interrupted Exception @throws KubernetesClientException KubernetesClientException @throws IOException IOException
[ "Replace", "a", "resource", "optionally", "performing", "placeholder", "substitution", "to", "the", "response", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java#L269-L273
15,763
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java
OperationSupport.handlePatch
protected <T> T handlePatch(T current, T updated, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { JsonNode diff = JsonDiff.asJson(patchMapper().valueToTree(current), patchMapper().valueToTree(updated)); RequestBody body = RequestBody.create(JSON_PATCH, JSON_MAPPER.writeValueAsString(diff)); Request.Builder requestBuilder = new Request.Builder().patch(body).url(getResourceUrl(checkNamespace(updated), checkName(updated))); return handleResponse(requestBuilder, type, Collections.<String, String>emptyMap()); }
java
protected <T> T handlePatch(T current, T updated, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { JsonNode diff = JsonDiff.asJson(patchMapper().valueToTree(current), patchMapper().valueToTree(updated)); RequestBody body = RequestBody.create(JSON_PATCH, JSON_MAPPER.writeValueAsString(diff)); Request.Builder requestBuilder = new Request.Builder().patch(body).url(getResourceUrl(checkNamespace(updated), checkName(updated))); return handleResponse(requestBuilder, type, Collections.<String, String>emptyMap()); }
[ "protected", "<", "T", ">", "T", "handlePatch", "(", "T", "current", ",", "T", "updated", ",", "Class", "<", "T", ">", "type", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "KubernetesClientException", ",", "IOException", "{", "JsonNode", "diff", "=", "JsonDiff", ".", "asJson", "(", "patchMapper", "(", ")", ".", "valueToTree", "(", "current", ")", ",", "patchMapper", "(", ")", ".", "valueToTree", "(", "updated", ")", ")", ";", "RequestBody", "body", "=", "RequestBody", ".", "create", "(", "JSON_PATCH", ",", "JSON_MAPPER", ".", "writeValueAsString", "(", "diff", ")", ")", ";", "Request", ".", "Builder", "requestBuilder", "=", "new", "Request", ".", "Builder", "(", ")", ".", "patch", "(", "body", ")", ".", "url", "(", "getResourceUrl", "(", "checkNamespace", "(", "updated", ")", ",", "checkName", "(", "updated", ")", ")", ")", ";", "return", "handleResponse", "(", "requestBuilder", ",", "type", ",", "Collections", ".", "<", "String", ",", "String", ">", "emptyMap", "(", ")", ")", ";", "}" ]
Send an http patch and handle the response. @param current current object @param updated updated object @param type type of object @param <T> template argument provided @return returns de-serialized version of api server response @throws ExecutionException Execution Exception @throws InterruptedException Interrupted Exception @throws KubernetesClientException KubernetesClientException @throws IOException IOException
[ "Send", "an", "http", "patch", "and", "handle", "the", "response", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java#L289-L294
15,764
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java
OperationSupport.handleGet
protected <T> T handleGet(URL resourceUrl, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { return handleGet(resourceUrl, type, Collections.<String, String>emptyMap()); }
java
protected <T> T handleGet(URL resourceUrl, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { return handleGet(resourceUrl, type, Collections.<String, String>emptyMap()); }
[ "protected", "<", "T", ">", "T", "handleGet", "(", "URL", "resourceUrl", ",", "Class", "<", "T", ">", "type", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "KubernetesClientException", ",", "IOException", "{", "return", "handleGet", "(", "resourceUrl", ",", "type", ",", "Collections", ".", "<", "String", ",", "String", ">", "emptyMap", "(", ")", ")", ";", "}" ]
Send an http get. @param resourceUrl resource URL to be processed @param type type of resource @param <T> template argument provided @return returns a deserialized object as api server response of provided type. @throws ExecutionException Execution Exception @throws InterruptedException Interrupted Exception @throws KubernetesClientException KubernetesClientException @throws IOException IOException
[ "Send", "an", "http", "get", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java#L310-L312
15,765
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java
OperationSupport.handleGet
protected <T> T handleGet(URL resourceUrl, Class<T> type, Map<String, String> parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { Request.Builder requestBuilder = new Request.Builder().get().url(resourceUrl); return handleResponse(requestBuilder, type, parameters); }
java
protected <T> T handleGet(URL resourceUrl, Class<T> type, Map<String, String> parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { Request.Builder requestBuilder = new Request.Builder().get().url(resourceUrl); return handleResponse(requestBuilder, type, parameters); }
[ "protected", "<", "T", ">", "T", "handleGet", "(", "URL", "resourceUrl", ",", "Class", "<", "T", ">", "type", ",", "Map", "<", "String", ",", "String", ">", "parameters", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "KubernetesClientException", ",", "IOException", "{", "Request", ".", "Builder", "requestBuilder", "=", "new", "Request", ".", "Builder", "(", ")", ".", "get", "(", ")", ".", "url", "(", "resourceUrl", ")", ";", "return", "handleResponse", "(", "requestBuilder", ",", "type", ",", "parameters", ")", ";", "}" ]
Send an http, optionally performing placeholder substitution to the response. @param resourceUrl resource URL to be processed @param type type of resource @param parameters A HashMap of strings containing parameters to be passed in request @param <T> template argument provided @return Returns a deserialized object as api server response of provided type. @throws ExecutionException Execution Exception @throws InterruptedException Interrupted Exception @throws KubernetesClientException KubernetesClientException @throws IOException IOException
[ "Send", "an", "http", "optionally", "performing", "placeholder", "substitution", "to", "the", "response", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java#L328-L331
15,766
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java
OperationSupport.handleResponse
protected <T> T handleResponse(Request.Builder requestBuilder, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { return handleResponse(requestBuilder, type, Collections.<String, String>emptyMap()); }
java
protected <T> T handleResponse(Request.Builder requestBuilder, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { return handleResponse(requestBuilder, type, Collections.<String, String>emptyMap()); }
[ "protected", "<", "T", ">", "T", "handleResponse", "(", "Request", ".", "Builder", "requestBuilder", ",", "Class", "<", "T", ">", "type", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "KubernetesClientException", ",", "IOException", "{", "return", "handleResponse", "(", "requestBuilder", ",", "type", ",", "Collections", ".", "<", "String", ",", "String", ">", "emptyMap", "(", ")", ")", ";", "}" ]
Send an http request and handle the response. @param requestBuilder Request Builder object @param type type of resource @param <T> template argument provided @return Returns a de-serialized object as api server response of provided type. @throws ExecutionException Execution Exception @throws InterruptedException Interrupted Exception @throws KubernetesClientException KubernetesClientException @throws IOException IOException
[ "Send", "an", "http", "request", "and", "handle", "the", "response", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java#L346-L348
15,767
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java
OperationSupport.handleResponse
protected <T> T handleResponse(OkHttpClient client, Request.Builder requestBuilder, Class<T> type, Map<String, String> parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { VersionUsageUtils.log(this.resourceT, this.apiGroupVersion); Request request = requestBuilder.build(); Response response = client.newCall(request).execute(); try (ResponseBody body = response.body()) { assertResponseCode(request, response); if (type != null) { try (InputStream bodyInputStream = body.byteStream()) { return Serialization.unmarshal(bodyInputStream, type, parameters); } } else { return null; } } catch (Exception e) { if (e instanceof KubernetesClientException) { throw e; } throw requestException(request, e); } finally { if(response != null && response.body() != null) { response.body().close(); } } }
java
protected <T> T handleResponse(OkHttpClient client, Request.Builder requestBuilder, Class<T> type, Map<String, String> parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOException { VersionUsageUtils.log(this.resourceT, this.apiGroupVersion); Request request = requestBuilder.build(); Response response = client.newCall(request).execute(); try (ResponseBody body = response.body()) { assertResponseCode(request, response); if (type != null) { try (InputStream bodyInputStream = body.byteStream()) { return Serialization.unmarshal(bodyInputStream, type, parameters); } } else { return null; } } catch (Exception e) { if (e instanceof KubernetesClientException) { throw e; } throw requestException(request, e); } finally { if(response != null && response.body() != null) { response.body().close(); } } }
[ "protected", "<", "T", ">", "T", "handleResponse", "(", "OkHttpClient", "client", ",", "Request", ".", "Builder", "requestBuilder", ",", "Class", "<", "T", ">", "type", ",", "Map", "<", "String", ",", "String", ">", "parameters", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "KubernetesClientException", ",", "IOException", "{", "VersionUsageUtils", ".", "log", "(", "this", ".", "resourceT", ",", "this", ".", "apiGroupVersion", ")", ";", "Request", "request", "=", "requestBuilder", ".", "build", "(", ")", ";", "Response", "response", "=", "client", ".", "newCall", "(", "request", ")", ".", "execute", "(", ")", ";", "try", "(", "ResponseBody", "body", "=", "response", ".", "body", "(", ")", ")", "{", "assertResponseCode", "(", "request", ",", "response", ")", ";", "if", "(", "type", "!=", "null", ")", "{", "try", "(", "InputStream", "bodyInputStream", "=", "body", ".", "byteStream", "(", ")", ")", "{", "return", "Serialization", ".", "unmarshal", "(", "bodyInputStream", ",", "type", ",", "parameters", ")", ";", "}", "}", "else", "{", "return", "null", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "if", "(", "e", "instanceof", "KubernetesClientException", ")", "{", "throw", "e", ";", "}", "throw", "requestException", "(", "request", ",", "e", ")", ";", "}", "finally", "{", "if", "(", "response", "!=", "null", "&&", "response", ".", "body", "(", ")", "!=", "null", ")", "{", "response", ".", "body", "(", ")", ".", "close", "(", ")", ";", "}", "}", "}" ]
Send an http request and handle the response, optionally performing placeholder substitution to the response. @param client OkHttp client provided @param requestBuilder Request builder @param type Type of object provided @param parameters A hashmap containing parameters @param <T> Template argument provided @return Returns a de-serialized object as api server response of provided type. @throws ExecutionException Execution Exception @throws InterruptedException Interrupted Exception @throws KubernetesClientException KubernetesClientException @throws IOException IOException
[ "Send", "an", "http", "request", "and", "handle", "the", "response", "optionally", "performing", "placeholder", "substitution", "to", "the", "response", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java#L401-L424
15,768
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java
OperationSupport.assertResponseCode
protected void assertResponseCode(Request request, Response response) { int statusCode = response.code(); String customMessage = config.getErrorMessages().get(statusCode); if (response.isSuccessful()) { return; } else if (customMessage != null) { throw requestFailure(request, createStatus(statusCode, combineMessages(customMessage, createStatus(response)))); } else { throw requestFailure(request, createStatus(response)); } }
java
protected void assertResponseCode(Request request, Response response) { int statusCode = response.code(); String customMessage = config.getErrorMessages().get(statusCode); if (response.isSuccessful()) { return; } else if (customMessage != null) { throw requestFailure(request, createStatus(statusCode, combineMessages(customMessage, createStatus(response)))); } else { throw requestFailure(request, createStatus(response)); } }
[ "protected", "void", "assertResponseCode", "(", "Request", "request", ",", "Response", "response", ")", "{", "int", "statusCode", "=", "response", ".", "code", "(", ")", ";", "String", "customMessage", "=", "config", ".", "getErrorMessages", "(", ")", ".", "get", "(", "statusCode", ")", ";", "if", "(", "response", ".", "isSuccessful", "(", ")", ")", "{", "return", ";", "}", "else", "if", "(", "customMessage", "!=", "null", ")", "{", "throw", "requestFailure", "(", "request", ",", "createStatus", "(", "statusCode", ",", "combineMessages", "(", "customMessage", ",", "createStatus", "(", "response", ")", ")", ")", ")", ";", "}", "else", "{", "throw", "requestFailure", "(", "request", ",", "createStatus", "(", "response", ")", ")", ";", "}", "}" ]
Checks if the response status code is the expected and throws the appropriate KubernetesClientException if not. @param request The {#link Request} object. @param response The {@link Response} object. @throws KubernetesClientException When the response code is not the expected.
[ "Checks", "if", "the", "response", "status", "code", "is", "the", "expected", "and", "throws", "the", "appropriate", "KubernetesClientException", "if", "not", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java#L433-L444
15,769
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/JobOperationsImpl.java
JobOperationsImpl.waitUntilJobIsScaled
private void waitUntilJobIsScaled() { final CountDownLatch countDownLatch = new CountDownLatch(1); final AtomicReference<Job> atomicJob = new AtomicReference<>(); final Runnable jobPoller = () -> { try { Job job = getMandatory(); atomicJob.set(job); Integer activeJobs = job.getStatus().getActive(); if (activeJobs == null) { activeJobs = 0; } if (Objects.equals(job.getSpec().getParallelism(), activeJobs)) { countDownLatch.countDown(); } else { LOG.debug("Only {}/{} pods scheduled for Job: {} in namespace: {} seconds so waiting...", job.getStatus().getActive(), job.getSpec().getParallelism(), job.getMetadata().getName(), namespace); } } catch (Throwable t) { LOG.error("Error while waiting for Job to be scaled.", t); } }; ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); ScheduledFuture poller = executor.scheduleWithFixedDelay(jobPoller, 0, POLL_INTERVAL_MS, TimeUnit.MILLISECONDS); try { countDownLatch.await(getConfig().getScaleTimeout(), TimeUnit.MILLISECONDS); executor.shutdown(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); poller.cancel(true); executor.shutdown(); LOG.error("Only {}/{} pod(s) ready for Job: {} in namespace: {} - giving up", atomicJob.get().getStatus().getActive(), atomicJob.get().getSpec().getParallelism(), atomicJob.get().getMetadata().getName(), namespace); } }
java
private void waitUntilJobIsScaled() { final CountDownLatch countDownLatch = new CountDownLatch(1); final AtomicReference<Job> atomicJob = new AtomicReference<>(); final Runnable jobPoller = () -> { try { Job job = getMandatory(); atomicJob.set(job); Integer activeJobs = job.getStatus().getActive(); if (activeJobs == null) { activeJobs = 0; } if (Objects.equals(job.getSpec().getParallelism(), activeJobs)) { countDownLatch.countDown(); } else { LOG.debug("Only {}/{} pods scheduled for Job: {} in namespace: {} seconds so waiting...", job.getStatus().getActive(), job.getSpec().getParallelism(), job.getMetadata().getName(), namespace); } } catch (Throwable t) { LOG.error("Error while waiting for Job to be scaled.", t); } }; ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); ScheduledFuture poller = executor.scheduleWithFixedDelay(jobPoller, 0, POLL_INTERVAL_MS, TimeUnit.MILLISECONDS); try { countDownLatch.await(getConfig().getScaleTimeout(), TimeUnit.MILLISECONDS); executor.shutdown(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); poller.cancel(true); executor.shutdown(); LOG.error("Only {}/{} pod(s) ready for Job: {} in namespace: {} - giving up", atomicJob.get().getStatus().getActive(), atomicJob.get().getSpec().getParallelism(), atomicJob.get().getMetadata().getName(), namespace); } }
[ "private", "void", "waitUntilJobIsScaled", "(", ")", "{", "final", "CountDownLatch", "countDownLatch", "=", "new", "CountDownLatch", "(", "1", ")", ";", "final", "AtomicReference", "<", "Job", ">", "atomicJob", "=", "new", "AtomicReference", "<>", "(", ")", ";", "final", "Runnable", "jobPoller", "=", "(", ")", "->", "{", "try", "{", "Job", "job", "=", "getMandatory", "(", ")", ";", "atomicJob", ".", "set", "(", "job", ")", ";", "Integer", "activeJobs", "=", "job", ".", "getStatus", "(", ")", ".", "getActive", "(", ")", ";", "if", "(", "activeJobs", "==", "null", ")", "{", "activeJobs", "=", "0", ";", "}", "if", "(", "Objects", ".", "equals", "(", "job", ".", "getSpec", "(", ")", ".", "getParallelism", "(", ")", ",", "activeJobs", ")", ")", "{", "countDownLatch", ".", "countDown", "(", ")", ";", "}", "else", "{", "LOG", ".", "debug", "(", "\"Only {}/{} pods scheduled for Job: {} in namespace: {} seconds so waiting...\"", ",", "job", ".", "getStatus", "(", ")", ".", "getActive", "(", ")", ",", "job", ".", "getSpec", "(", ")", ".", "getParallelism", "(", ")", ",", "job", ".", "getMetadata", "(", ")", ".", "getName", "(", ")", ",", "namespace", ")", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "LOG", ".", "error", "(", "\"Error while waiting for Job to be scaled.\"", ",", "t", ")", ";", "}", "}", ";", "ScheduledExecutorService", "executor", "=", "Executors", ".", "newSingleThreadScheduledExecutor", "(", ")", ";", "ScheduledFuture", "poller", "=", "executor", ".", "scheduleWithFixedDelay", "(", "jobPoller", ",", "0", ",", "POLL_INTERVAL_MS", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "try", "{", "countDownLatch", ".", "await", "(", "getConfig", "(", ")", ".", "getScaleTimeout", "(", ")", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "executor", ".", "shutdown", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "Thread", ".", "currentThread", "(", ")", ".", "interrupt", "(", ")", ";", "poller", ".", "cancel", "(", "true", ")", ";", "executor", ".", "shutdown", "(", ")", ";", "LOG", ".", "error", "(", "\"Only {}/{} pod(s) ready for Job: {} in namespace: {} - giving up\"", ",", "atomicJob", ".", "get", "(", ")", ".", "getStatus", "(", ")", ".", "getActive", "(", ")", ",", "atomicJob", ".", "get", "(", ")", ".", "getSpec", "(", ")", ".", "getParallelism", "(", ")", ",", "atomicJob", ".", "get", "(", ")", ".", "getMetadata", "(", ")", ".", "getName", "(", ")", ",", "namespace", ")", ";", "}", "}" ]
Lets wait until there are enough Ready pods of the given Job
[ "Lets", "wait", "until", "there", "are", "enough", "Ready", "pods", "of", "the", "given", "Job" ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/JobOperationsImpl.java#L97-L133
15,770
fabric8io/kubernetes-client
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Config.java
Config.autoConfigure
public static Config autoConfigure(String context) { Config config = new Config(); return autoConfigure(config, context); }
java
public static Config autoConfigure(String context) { Config config = new Config(); return autoConfigure(config, context); }
[ "public", "static", "Config", "autoConfigure", "(", "String", "context", ")", "{", "Config", "config", "=", "new", "Config", "(", ")", ";", "return", "autoConfigure", "(", "config", ",", "context", ")", ";", "}" ]
Does auto detection with some opinionated defaults. @param context if null will use current-context @return Config object
[ "Does", "auto", "detection", "with", "some", "opinionated", "defaults", "." ]
141668a882ed8e902c045a5cd0a80f14bd17d132
https://github.com/fabric8io/kubernetes-client/blob/141668a882ed8e902c045a5cd0a80f14bd17d132/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Config.java#L209-L212
15,771
yidongnan/grpc-spring-boot-starter
grpc-common-spring-boot/src/main/java/net/devh/boot/grpc/common/metric/MetricUtils.java
MetricUtils.prepareCounterFor
public static Counter.Builder prepareCounterFor(final MethodDescriptor<?, ?> method, final String name, final String description) { return Counter.builder(name) .description(description) .baseUnit("messages") .tag(TAG_SERVICE_NAME, extractServiceName(method)) .tag(TAG_METHOD_NAME, extractMethodName(method)); }
java
public static Counter.Builder prepareCounterFor(final MethodDescriptor<?, ?> method, final String name, final String description) { return Counter.builder(name) .description(description) .baseUnit("messages") .tag(TAG_SERVICE_NAME, extractServiceName(method)) .tag(TAG_METHOD_NAME, extractMethodName(method)); }
[ "public", "static", "Counter", ".", "Builder", "prepareCounterFor", "(", "final", "MethodDescriptor", "<", "?", ",", "?", ">", "method", ",", "final", "String", "name", ",", "final", "String", "description", ")", "{", "return", "Counter", ".", "builder", "(", "name", ")", ".", "description", "(", "description", ")", ".", "baseUnit", "(", "\"messages\"", ")", ".", "tag", "(", "TAG_SERVICE_NAME", ",", "extractServiceName", "(", "method", ")", ")", ".", "tag", "(", "TAG_METHOD_NAME", ",", "extractMethodName", "(", "method", ")", ")", ";", "}" ]
Creates a new counter builder for the given method. By default the base unit will be messages. @param method The method the counter will be created for. @param name The name of the counter to use. @param description The description of the counter to use. @return The newly created counter builder.
[ "Creates", "a", "new", "counter", "builder", "for", "the", "given", "method", ".", "By", "default", "the", "base", "unit", "will", "be", "messages", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-common-spring-boot/src/main/java/net/devh/boot/grpc/common/metric/MetricUtils.java#L45-L52
15,772
yidongnan/grpc-spring-boot-starter
grpc-common-spring-boot/src/main/java/net/devh/boot/grpc/common/metric/MetricUtils.java
MetricUtils.prepareTimerFor
public static Timer.Builder prepareTimerFor(final MethodDescriptor<?, ?> method, final String name, final String description) { return Timer.builder(name) .description(description) .tag(TAG_SERVICE_NAME, extractServiceName(method)) .tag(TAG_METHOD_NAME, extractMethodName(method)); }
java
public static Timer.Builder prepareTimerFor(final MethodDescriptor<?, ?> method, final String name, final String description) { return Timer.builder(name) .description(description) .tag(TAG_SERVICE_NAME, extractServiceName(method)) .tag(TAG_METHOD_NAME, extractMethodName(method)); }
[ "public", "static", "Timer", ".", "Builder", "prepareTimerFor", "(", "final", "MethodDescriptor", "<", "?", ",", "?", ">", "method", ",", "final", "String", "name", ",", "final", "String", "description", ")", "{", "return", "Timer", ".", "builder", "(", "name", ")", ".", "description", "(", "description", ")", ".", "tag", "(", "TAG_SERVICE_NAME", ",", "extractServiceName", "(", "method", ")", ")", ".", "tag", "(", "TAG_METHOD_NAME", ",", "extractMethodName", "(", "method", ")", ")", ";", "}" ]
Creates a new timer builder for the given method. @param method The method the timer will be created for. @param name The name of the timer to use. @param description The description of the timer to use. @return The newly created timer builder.
[ "Creates", "a", "new", "timer", "builder", "for", "the", "given", "method", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-common-spring-boot/src/main/java/net/devh/boot/grpc/common/metric/MetricUtils.java#L62-L68
15,773
yidongnan/grpc-spring-boot-starter
grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/security/authentication/X509CertificateAuthenticationProvider.java
X509CertificateAuthenticationProvider.patternExtractor
public static Function<X509CertificateAuthentication, String> patternExtractor(final String key, final Function<? super X509CertificateAuthentication, String> fallback) { requireNonNull(key, "key"); requireNonNull(fallback, "fallback"); final Pattern pattern = Pattern.compile(key + "=(.+?)(?:,|$)", Pattern.CASE_INSENSITIVE); return authentication -> { final Object principal = authentication.getPrincipal(); if (principal instanceof X500Principal) { final X500Principal x500Principal = (X500Principal) principal; final Matcher matcher = pattern.matcher(x500Principal.getName()); if (matcher.find()) { return matcher.group(1); } } return fallback.apply(authentication); }; }
java
public static Function<X509CertificateAuthentication, String> patternExtractor(final String key, final Function<? super X509CertificateAuthentication, String> fallback) { requireNonNull(key, "key"); requireNonNull(fallback, "fallback"); final Pattern pattern = Pattern.compile(key + "=(.+?)(?:,|$)", Pattern.CASE_INSENSITIVE); return authentication -> { final Object principal = authentication.getPrincipal(); if (principal instanceof X500Principal) { final X500Principal x500Principal = (X500Principal) principal; final Matcher matcher = pattern.matcher(x500Principal.getName()); if (matcher.find()) { return matcher.group(1); } } return fallback.apply(authentication); }; }
[ "public", "static", "Function", "<", "X509CertificateAuthentication", ",", "String", ">", "patternExtractor", "(", "final", "String", "key", ",", "final", "Function", "<", "?", "super", "X509CertificateAuthentication", ",", "String", ">", "fallback", ")", "{", "requireNonNull", "(", "key", ",", "\"key\"", ")", ";", "requireNonNull", "(", "fallback", ",", "\"fallback\"", ")", ";", "final", "Pattern", "pattern", "=", "Pattern", ".", "compile", "(", "key", "+", "\"=(.+?)(?:,|$)\"", ",", "Pattern", ".", "CASE_INSENSITIVE", ")", ";", "return", "authentication", "->", "{", "final", "Object", "principal", "=", "authentication", ".", "getPrincipal", "(", ")", ";", "if", "(", "principal", "instanceof", "X500Principal", ")", "{", "final", "X500Principal", "x500Principal", "=", "(", "X500Principal", ")", "principal", ";", "final", "Matcher", "matcher", "=", "pattern", ".", "matcher", "(", "x500Principal", ".", "getName", "(", ")", ")", ";", "if", "(", "matcher", ".", "find", "(", ")", ")", "{", "return", "matcher", ".", "group", "(", "1", ")", ";", "}", "}", "return", "fallback", ".", "apply", "(", "authentication", ")", ";", "}", ";", "}" ]
Creates a new case-insensitive pattern extractor with the given pattern. @param key The case insensitive key to use (Example: 'CN'). @param fallback The fallback function to use if the key was not present in the subject. @return The newly created extractor.
[ "Creates", "a", "new", "case", "-", "insensitive", "pattern", "extractor", "with", "the", "given", "pattern", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/security/authentication/X509CertificateAuthenticationProvider.java#L72-L88
15,774
yidongnan/grpc-spring-boot-starter
grpc-common-spring-boot/src/main/java/net/devh/boot/grpc/common/util/GrpcUtils.java
GrpcUtils.extractMethodName
public static String extractMethodName(final MethodDescriptor<?, ?> method) { // This method is the equivalent of MethodDescriptor.extractFullServiceName final String fullMethodName = method.getFullMethodName(); final int index = fullMethodName.lastIndexOf('/'); if (index == -1) { return fullMethodName; } return fullMethodName.substring(index + 1); }
java
public static String extractMethodName(final MethodDescriptor<?, ?> method) { // This method is the equivalent of MethodDescriptor.extractFullServiceName final String fullMethodName = method.getFullMethodName(); final int index = fullMethodName.lastIndexOf('/'); if (index == -1) { return fullMethodName; } return fullMethodName.substring(index + 1); }
[ "public", "static", "String", "extractMethodName", "(", "final", "MethodDescriptor", "<", "?", ",", "?", ">", "method", ")", "{", "// This method is the equivalent of MethodDescriptor.extractFullServiceName", "final", "String", "fullMethodName", "=", "method", ".", "getFullMethodName", "(", ")", ";", "final", "int", "index", "=", "fullMethodName", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "index", "==", "-", "1", ")", "{", "return", "fullMethodName", ";", "}", "return", "fullMethodName", ".", "substring", "(", "index", "+", "1", ")", ";", "}" ]
Extracts the method name from the given method. @param method The method to get the method name from. @return The extracted method name. @see #extractServiceName(MethodDescriptor)
[ "Extracts", "the", "method", "name", "from", "the", "given", "method", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-common-spring-boot/src/main/java/net/devh/boot/grpc/common/util/GrpcUtils.java#L48-L56
15,775
yidongnan/grpc-spring-boot-starter
grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/autoconfigure/GrpcServerMetricAutoConfiguration.java
GrpcServerMetricAutoConfiguration.collectMethodNamesForService
protected List<String> collectMethodNamesForService(final ServiceDescriptor serviceDescriptor) { final List<String> methods = new ArrayList<>(); for (final MethodDescriptor<?, ?> grpcMethod : serviceDescriptor.getMethods()) { methods.add(extractMethodName(grpcMethod)); } methods.sort(String.CASE_INSENSITIVE_ORDER); return methods; }
java
protected List<String> collectMethodNamesForService(final ServiceDescriptor serviceDescriptor) { final List<String> methods = new ArrayList<>(); for (final MethodDescriptor<?, ?> grpcMethod : serviceDescriptor.getMethods()) { methods.add(extractMethodName(grpcMethod)); } methods.sort(String.CASE_INSENSITIVE_ORDER); return methods; }
[ "protected", "List", "<", "String", ">", "collectMethodNamesForService", "(", "final", "ServiceDescriptor", "serviceDescriptor", ")", "{", "final", "List", "<", "String", ">", "methods", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "final", "MethodDescriptor", "<", "?", ",", "?", ">", "grpcMethod", ":", "serviceDescriptor", ".", "getMethods", "(", ")", ")", "{", "methods", ".", "add", "(", "extractMethodName", "(", "grpcMethod", ")", ")", ";", "}", "methods", ".", "sort", "(", "String", ".", "CASE_INSENSITIVE_ORDER", ")", ";", "return", "methods", ";", "}" ]
Gets all method names from the given service descriptor. @param serviceDescriptor The service descriptor to get the names from. @return The newly created and sorted list of the method names.
[ "Gets", "all", "method", "names", "from", "the", "given", "service", "descriptor", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/autoconfigure/GrpcServerMetricAutoConfiguration.java#L108-L115
15,776
yidongnan/grpc-spring-boot-starter
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/autoconfigure/GrpcClientAutoConfiguration.java
GrpcClientAutoConfiguration.grpcLoadBalancerConfigurer
@ConditionalOnSingleCandidate(LoadBalancer.Factory.class) @ConditionalOnMissingBean(name = "grpcLoadBalancerConfigurer") @Bean @SuppressWarnings("deprecation") @Deprecated public GrpcChannelConfigurer grpcLoadBalancerConfigurer(final LoadBalancer.Factory loadBalancerFactory) { return (channel, name) -> channel.loadBalancerFactory(loadBalancerFactory); }
java
@ConditionalOnSingleCandidate(LoadBalancer.Factory.class) @ConditionalOnMissingBean(name = "grpcLoadBalancerConfigurer") @Bean @SuppressWarnings("deprecation") @Deprecated public GrpcChannelConfigurer grpcLoadBalancerConfigurer(final LoadBalancer.Factory loadBalancerFactory) { return (channel, name) -> channel.loadBalancerFactory(loadBalancerFactory); }
[ "@", "ConditionalOnSingleCandidate", "(", "LoadBalancer", ".", "Factory", ".", "class", ")", "@", "ConditionalOnMissingBean", "(", "name", "=", "\"grpcLoadBalancerConfigurer\"", ")", "@", "Bean", "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "@", "Deprecated", "public", "GrpcChannelConfigurer", "grpcLoadBalancerConfigurer", "(", "final", "LoadBalancer", ".", "Factory", "loadBalancerFactory", ")", "{", "return", "(", "channel", ",", "name", ")", "->", "channel", ".", "loadBalancerFactory", "(", "loadBalancerFactory", ")", ";", "}" ]
Creates the load balancer configurer bean for the given load balancer factory. @param loadBalancerFactory The factory that should be used for all @return The load balancer factory bean. @see ManagedChannelBuilder#loadBalancerFactory(io.grpc.LoadBalancer.Factory) @deprecated This method disables service-config-based policy selection, and may cause problems if NameResolver returns GRPCLB balancer addresses but a non-GRPCLB LoadBalancer is passed in here. Use {@link GrpcChannelProperties#setDefaultLoadBalancingPolicy(String)} instead.
[ "Creates", "the", "load", "balancer", "configurer", "bean", "for", "the", "given", "load", "balancer", "factory", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/autoconfigure/GrpcClientAutoConfiguration.java#L101-L108
15,777
yidongnan/grpc-spring-boot-starter
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/autoconfigure/GrpcClientAutoConfiguration.java
GrpcClientAutoConfiguration.nettyGrpcChannelFactory
@ConditionalOnMissingBean(GrpcChannelFactory.class) @ConditionalOnClass(name = {"io.netty.channel.Channel", "io.grpc.netty.NettyChannelBuilder"}) @Bean public GrpcChannelFactory nettyGrpcChannelFactory(final GrpcChannelsProperties properties, final NameResolver.Factory nameResolverFactory, final GlobalClientInterceptorRegistry globalClientInterceptorRegistry, final List<GrpcChannelConfigurer> channelConfigurers) { final NettyChannelFactory channelFactory = new NettyChannelFactory(properties, nameResolverFactory, globalClientInterceptorRegistry, channelConfigurers); final InProcessChannelFactory inProcessChannelFactory = new InProcessChannelFactory(properties, globalClientInterceptorRegistry, channelConfigurers); return new InProcessOrAlternativeChannelFactory(properties, inProcessChannelFactory, channelFactory); }
java
@ConditionalOnMissingBean(GrpcChannelFactory.class) @ConditionalOnClass(name = {"io.netty.channel.Channel", "io.grpc.netty.NettyChannelBuilder"}) @Bean public GrpcChannelFactory nettyGrpcChannelFactory(final GrpcChannelsProperties properties, final NameResolver.Factory nameResolverFactory, final GlobalClientInterceptorRegistry globalClientInterceptorRegistry, final List<GrpcChannelConfigurer> channelConfigurers) { final NettyChannelFactory channelFactory = new NettyChannelFactory(properties, nameResolverFactory, globalClientInterceptorRegistry, channelConfigurers); final InProcessChannelFactory inProcessChannelFactory = new InProcessChannelFactory(properties, globalClientInterceptorRegistry, channelConfigurers); return new InProcessOrAlternativeChannelFactory(properties, inProcessChannelFactory, channelFactory); }
[ "@", "ConditionalOnMissingBean", "(", "GrpcChannelFactory", ".", "class", ")", "@", "ConditionalOnClass", "(", "name", "=", "{", "\"io.netty.channel.Channel\"", ",", "\"io.grpc.netty.NettyChannelBuilder\"", "}", ")", "@", "Bean", "public", "GrpcChannelFactory", "nettyGrpcChannelFactory", "(", "final", "GrpcChannelsProperties", "properties", ",", "final", "NameResolver", ".", "Factory", "nameResolverFactory", ",", "final", "GlobalClientInterceptorRegistry", "globalClientInterceptorRegistry", ",", "final", "List", "<", "GrpcChannelConfigurer", ">", "channelConfigurers", ")", "{", "final", "NettyChannelFactory", "channelFactory", "=", "new", "NettyChannelFactory", "(", "properties", ",", "nameResolverFactory", ",", "globalClientInterceptorRegistry", ",", "channelConfigurers", ")", ";", "final", "InProcessChannelFactory", "inProcessChannelFactory", "=", "new", "InProcessChannelFactory", "(", "properties", ",", "globalClientInterceptorRegistry", ",", "channelConfigurers", ")", ";", "return", "new", "InProcessOrAlternativeChannelFactory", "(", "properties", ",", "inProcessChannelFactory", ",", "channelFactory", ")", ";", "}" ]
Then try the normal netty channel factory
[ "Then", "try", "the", "normal", "netty", "channel", "factory" ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/autoconfigure/GrpcClientAutoConfiguration.java#L171-L184
15,778
yidongnan/grpc-spring-boot-starter
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/autoconfigure/GrpcClientAutoConfiguration.java
GrpcClientAutoConfiguration.inProcessGrpcChannelFactory
@ConditionalOnMissingBean(GrpcChannelFactory.class) @Bean public GrpcChannelFactory inProcessGrpcChannelFactory(final GrpcChannelsProperties properties, final GlobalClientInterceptorRegistry globalClientInterceptorRegistry, final List<GrpcChannelConfigurer> channelConfigurers) { return new InProcessChannelFactory(properties, globalClientInterceptorRegistry, channelConfigurers); }
java
@ConditionalOnMissingBean(GrpcChannelFactory.class) @Bean public GrpcChannelFactory inProcessGrpcChannelFactory(final GrpcChannelsProperties properties, final GlobalClientInterceptorRegistry globalClientInterceptorRegistry, final List<GrpcChannelConfigurer> channelConfigurers) { return new InProcessChannelFactory(properties, globalClientInterceptorRegistry, channelConfigurers); }
[ "@", "ConditionalOnMissingBean", "(", "GrpcChannelFactory", ".", "class", ")", "@", "Bean", "public", "GrpcChannelFactory", "inProcessGrpcChannelFactory", "(", "final", "GrpcChannelsProperties", "properties", ",", "final", "GlobalClientInterceptorRegistry", "globalClientInterceptorRegistry", ",", "final", "List", "<", "GrpcChannelConfigurer", ">", "channelConfigurers", ")", "{", "return", "new", "InProcessChannelFactory", "(", "properties", ",", "globalClientInterceptorRegistry", ",", "channelConfigurers", ")", ";", "}" ]
Finally try the in process channel factory
[ "Finally", "try", "the", "in", "process", "channel", "factory" ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/autoconfigure/GrpcClientAutoConfiguration.java#L187-L193
15,779
yidongnan/grpc-spring-boot-starter
grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/autoconfigure/GrpcServerFactoryAutoConfiguration.java
GrpcServerFactoryAutoConfiguration.shadedNettyGrpcServerFactory
@ConditionalOnClass(name = {"io.grpc.netty.shaded.io.netty.channel.Channel", "io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder"}) @Bean public ShadedNettyGrpcServerFactory shadedNettyGrpcServerFactory(final GrpcServerProperties properties, final GrpcServiceDiscoverer serviceDiscoverer, final List<GrpcServerConfigurer> serverConfigurers) { final ShadedNettyGrpcServerFactory factory = new ShadedNettyGrpcServerFactory(properties, serverConfigurers); for (final GrpcServiceDefinition service : serviceDiscoverer.findGrpcServices()) { factory.addService(service); } return factory; }
java
@ConditionalOnClass(name = {"io.grpc.netty.shaded.io.netty.channel.Channel", "io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder"}) @Bean public ShadedNettyGrpcServerFactory shadedNettyGrpcServerFactory(final GrpcServerProperties properties, final GrpcServiceDiscoverer serviceDiscoverer, final List<GrpcServerConfigurer> serverConfigurers) { final ShadedNettyGrpcServerFactory factory = new ShadedNettyGrpcServerFactory(properties, serverConfigurers); for (final GrpcServiceDefinition service : serviceDiscoverer.findGrpcServices()) { factory.addService(service); } return factory; }
[ "@", "ConditionalOnClass", "(", "name", "=", "{", "\"io.grpc.netty.shaded.io.netty.channel.Channel\"", ",", "\"io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder\"", "}", ")", "@", "Bean", "public", "ShadedNettyGrpcServerFactory", "shadedNettyGrpcServerFactory", "(", "final", "GrpcServerProperties", "properties", ",", "final", "GrpcServiceDiscoverer", "serviceDiscoverer", ",", "final", "List", "<", "GrpcServerConfigurer", ">", "serverConfigurers", ")", "{", "final", "ShadedNettyGrpcServerFactory", "factory", "=", "new", "ShadedNettyGrpcServerFactory", "(", "properties", ",", "serverConfigurers", ")", ";", "for", "(", "final", "GrpcServiceDefinition", "service", ":", "serviceDiscoverer", ".", "findGrpcServices", "(", ")", ")", "{", "factory", ".", "addService", "(", "service", ")", ";", "}", "return", "factory", ";", "}" ]
Creates a GrpcServerFactory using the shaded netty. This is the recommended default for gRPC. @param properties The properties used to configure the server. @param serviceDiscoverer The discoverer used to identify the services that should be served. @param serverConfigurers The server configurers that contain additional configuration for the server. @return The shadedNettyGrpcServerFactory bean.
[ "Creates", "a", "GrpcServerFactory", "using", "the", "shaded", "netty", ".", "This", "is", "the", "recommended", "default", "for", "gRPC", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/autoconfigure/GrpcServerFactoryAutoConfiguration.java#L60-L70
15,780
yidongnan/grpc-spring-boot-starter
grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/autoconfigure/GrpcServerFactoryAutoConfiguration.java
GrpcServerFactoryAutoConfiguration.nettyGrpcServerFactory
@ConditionalOnMissingBean @ConditionalOnClass(name = {"io.netty.channel.Channel", "io.grpc.netty.NettyServerBuilder"}) @Bean public NettyGrpcServerFactory nettyGrpcServerFactory(final GrpcServerProperties properties, final GrpcServiceDiscoverer serviceDiscoverer, final List<GrpcServerConfigurer> serverConfigurers) { final NettyGrpcServerFactory factory = new NettyGrpcServerFactory(properties, serverConfigurers); for (final GrpcServiceDefinition service : serviceDiscoverer.findGrpcServices()) { factory.addService(service); } return factory; }
java
@ConditionalOnMissingBean @ConditionalOnClass(name = {"io.netty.channel.Channel", "io.grpc.netty.NettyServerBuilder"}) @Bean public NettyGrpcServerFactory nettyGrpcServerFactory(final GrpcServerProperties properties, final GrpcServiceDiscoverer serviceDiscoverer, final List<GrpcServerConfigurer> serverConfigurers) { final NettyGrpcServerFactory factory = new NettyGrpcServerFactory(properties, serverConfigurers); for (final GrpcServiceDefinition service : serviceDiscoverer.findGrpcServices()) { factory.addService(service); } return factory; }
[ "@", "ConditionalOnMissingBean", "@", "ConditionalOnClass", "(", "name", "=", "{", "\"io.netty.channel.Channel\"", ",", "\"io.grpc.netty.NettyServerBuilder\"", "}", ")", "@", "Bean", "public", "NettyGrpcServerFactory", "nettyGrpcServerFactory", "(", "final", "GrpcServerProperties", "properties", ",", "final", "GrpcServiceDiscoverer", "serviceDiscoverer", ",", "final", "List", "<", "GrpcServerConfigurer", ">", "serverConfigurers", ")", "{", "final", "NettyGrpcServerFactory", "factory", "=", "new", "NettyGrpcServerFactory", "(", "properties", ",", "serverConfigurers", ")", ";", "for", "(", "final", "GrpcServiceDefinition", "service", ":", "serviceDiscoverer", ".", "findGrpcServices", "(", ")", ")", "{", "factory", ".", "addService", "(", "service", ")", ";", "}", "return", "factory", ";", "}" ]
Creates a GrpcServerFactory using the non-shaded netty. This is the fallback, if the shaded one is not present. @param properties The properties used to configure the server. @param serviceDiscoverer The discoverer used to identify the services that should be served. @param serverConfigurers The server configurers that contain additional configuration for the server. @return The shadedNettyGrpcServerFactory bean.
[ "Creates", "a", "GrpcServerFactory", "using", "the", "non", "-", "shaded", "netty", ".", "This", "is", "the", "fallback", "if", "the", "shaded", "one", "is", "not", "present", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/autoconfigure/GrpcServerFactoryAutoConfiguration.java#L94-L104
15,781
yidongnan/grpc-spring-boot-starter
grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/autoconfigure/GrpcServerFactoryAutoConfiguration.java
GrpcServerFactoryAutoConfiguration.nettyGrpcServerLifecycle
@ConditionalOnMissingBean @ConditionalOnClass(name = {"io.netty.channel.Channel", "io.grpc.netty.NettyServerBuilder"}) @Bean public GrpcServerLifecycle nettyGrpcServerLifecycle(final NettyGrpcServerFactory factory) { return new GrpcServerLifecycle(factory); }
java
@ConditionalOnMissingBean @ConditionalOnClass(name = {"io.netty.channel.Channel", "io.grpc.netty.NettyServerBuilder"}) @Bean public GrpcServerLifecycle nettyGrpcServerLifecycle(final NettyGrpcServerFactory factory) { return new GrpcServerLifecycle(factory); }
[ "@", "ConditionalOnMissingBean", "@", "ConditionalOnClass", "(", "name", "=", "{", "\"io.netty.channel.Channel\"", ",", "\"io.grpc.netty.NettyServerBuilder\"", "}", ")", "@", "Bean", "public", "GrpcServerLifecycle", "nettyGrpcServerLifecycle", "(", "final", "NettyGrpcServerFactory", "factory", ")", "{", "return", "new", "GrpcServerLifecycle", "(", "factory", ")", ";", "}" ]
The server lifecycle bean for netty based server. @param factory The factory used to create the lifecycle. @return The inter-process server lifecycle bean.
[ "The", "server", "lifecycle", "bean", "for", "netty", "based", "server", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/autoconfigure/GrpcServerFactoryAutoConfiguration.java#L112-L117
15,782
yidongnan/grpc-spring-boot-starter
grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/autoconfigure/GrpcServerFactoryAutoConfiguration.java
GrpcServerFactoryAutoConfiguration.inProcessGrpcServerFactory
@ConditionalOnProperty(prefix = "grpc.server", name = "inProcessName") @Bean public InProcessGrpcServerFactory inProcessGrpcServerFactory(final GrpcServerProperties properties, final GrpcServiceDiscoverer serviceDiscoverer) { final InProcessGrpcServerFactory factory = new InProcessGrpcServerFactory(properties); for (final GrpcServiceDefinition service : serviceDiscoverer.findGrpcServices()) { factory.addService(service); } return factory; }
java
@ConditionalOnProperty(prefix = "grpc.server", name = "inProcessName") @Bean public InProcessGrpcServerFactory inProcessGrpcServerFactory(final GrpcServerProperties properties, final GrpcServiceDiscoverer serviceDiscoverer) { final InProcessGrpcServerFactory factory = new InProcessGrpcServerFactory(properties); for (final GrpcServiceDefinition service : serviceDiscoverer.findGrpcServices()) { factory.addService(service); } return factory; }
[ "@", "ConditionalOnProperty", "(", "prefix", "=", "\"grpc.server\"", ",", "name", "=", "\"inProcessName\"", ")", "@", "Bean", "public", "InProcessGrpcServerFactory", "inProcessGrpcServerFactory", "(", "final", "GrpcServerProperties", "properties", ",", "final", "GrpcServiceDiscoverer", "serviceDiscoverer", ")", "{", "final", "InProcessGrpcServerFactory", "factory", "=", "new", "InProcessGrpcServerFactory", "(", "properties", ")", ";", "for", "(", "final", "GrpcServiceDefinition", "service", ":", "serviceDiscoverer", ".", "findGrpcServices", "(", ")", ")", "{", "factory", ".", "addService", "(", "service", ")", ";", "}", "return", "factory", ";", "}" ]
Creates a GrpcServerFactory using the in-process-server, if a name is specified. @param properties The properties used to configure the server. @param serviceDiscoverer The discoverer used to identify the services that should be served. @return The shadedNettyGrpcServerFactory bean.
[ "Creates", "a", "GrpcServerFactory", "using", "the", "in", "-", "process", "-", "server", "if", "a", "name", "is", "specified", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/autoconfigure/GrpcServerFactoryAutoConfiguration.java#L126-L135
15,783
yidongnan/grpc-spring-boot-starter
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/config/GrpcChannelsProperties.java
GrpcChannelsProperties.getChannel
public GrpcChannelProperties getChannel(final String name) { final GrpcChannelProperties properties = getRawChannel(name); properties.copyDefaultsFrom(getGlobalChannel()); return properties; }
java
public GrpcChannelProperties getChannel(final String name) { final GrpcChannelProperties properties = getRawChannel(name); properties.copyDefaultsFrom(getGlobalChannel()); return properties; }
[ "public", "GrpcChannelProperties", "getChannel", "(", "final", "String", "name", ")", "{", "final", "GrpcChannelProperties", "properties", "=", "getRawChannel", "(", "name", ")", ";", "properties", ".", "copyDefaultsFrom", "(", "getGlobalChannel", "(", ")", ")", ";", "return", "properties", ";", "}" ]
Gets the properties for the given channel. If the properties for the specified channel name do not yet exist, they are created automatically. Before the instance is returned, the unset values are filled with values from the global properties. @param name The name of the channel to get the properties for. @return The properties for the given channel name.
[ "Gets", "the", "properties", "for", "the", "given", "channel", ".", "If", "the", "properties", "for", "the", "specified", "channel", "name", "do", "not", "yet", "exist", "they", "are", "created", "automatically", ".", "Before", "the", "instance", "is", "returned", "the", "unset", "values", "are", "filled", "with", "values", "from", "the", "global", "properties", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/config/GrpcChannelsProperties.java#L67-L71
15,784
yidongnan/grpc-spring-boot-starter
grpc-common-spring-boot/src/main/java/net/devh/boot/grpc/common/metric/AbstractMetricCollectingInterceptor.java
AbstractMetricCollectingInterceptor.asTimerFunction
protected Function<Code, Timer> asTimerFunction(final Supplier<Timer.Builder> timerTemplate) { final Map<Code, Timer> cache = new EnumMap<>(Code.class); final Function<Code, Timer> creator = code -> timerTemplate.get() .tag(TAG_STATUS_CODE, code.name()) .register(this.registry); final Function<Code, Timer> cacheResolver = code -> cache.computeIfAbsent(code, creator); // Eager initialize for (final Code code : this.eagerInitializedCodes) { cacheResolver.apply(code); } return cacheResolver; }
java
protected Function<Code, Timer> asTimerFunction(final Supplier<Timer.Builder> timerTemplate) { final Map<Code, Timer> cache = new EnumMap<>(Code.class); final Function<Code, Timer> creator = code -> timerTemplate.get() .tag(TAG_STATUS_CODE, code.name()) .register(this.registry); final Function<Code, Timer> cacheResolver = code -> cache.computeIfAbsent(code, creator); // Eager initialize for (final Code code : this.eagerInitializedCodes) { cacheResolver.apply(code); } return cacheResolver; }
[ "protected", "Function", "<", "Code", ",", "Timer", ">", "asTimerFunction", "(", "final", "Supplier", "<", "Timer", ".", "Builder", ">", "timerTemplate", ")", "{", "final", "Map", "<", "Code", ",", "Timer", ">", "cache", "=", "new", "EnumMap", "<>", "(", "Code", ".", "class", ")", ";", "final", "Function", "<", "Code", ",", "Timer", ">", "creator", "=", "code", "->", "timerTemplate", ".", "get", "(", ")", ".", "tag", "(", "TAG_STATUS_CODE", ",", "code", ".", "name", "(", ")", ")", ".", "register", "(", "this", ".", "registry", ")", ";", "final", "Function", "<", "Code", ",", "Timer", ">", "cacheResolver", "=", "code", "->", "cache", ".", "computeIfAbsent", "(", "code", ",", "creator", ")", ";", "// Eager initialize", "for", "(", "final", "Code", "code", ":", "this", ".", "eagerInitializedCodes", ")", "{", "cacheResolver", ".", "apply", "(", "code", ")", ";", "}", "return", "cacheResolver", ";", "}" ]
Creates a new timer function using the given template. This method initializes the default timers. @param timerTemplate The template to create the instances from. @return The newly created function that returns a timer for a given code.
[ "Creates", "a", "new", "timer", "function", "using", "the", "given", "template", ".", "This", "method", "initializes", "the", "default", "timers", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-common-spring-boot/src/main/java/net/devh/boot/grpc/common/metric/AbstractMetricCollectingInterceptor.java#L150-L161
15,785
yidongnan/grpc-spring-boot-starter
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/config/GrpcChannelProperties.java
GrpcChannelProperties.copyDefaultsFrom
public void copyDefaultsFrom(final GrpcChannelProperties config) { if (this == config) { return; } if (this.address == null) { this.address = config.address; } if (this.defaultLoadBalancingPolicy == null) { this.defaultLoadBalancingPolicy = config.defaultLoadBalancingPolicy; } if (this.enableKeepAlive == null) { this.enableKeepAlive = config.enableKeepAlive; } if (this.keepAliveTime == null) { this.keepAliveTime = config.keepAliveTime; } if (this.keepAliveTimeout == null) { this.keepAliveTimeout = config.keepAliveTimeout; } if (this.keepAliveWithoutCalls == null) { this.keepAliveWithoutCalls = config.keepAliveWithoutCalls; } if (this.maxInboundMessageSize == null) { this.maxInboundMessageSize = config.maxInboundMessageSize; } if (this.fullStreamDecompression == null) { this.fullStreamDecompression = config.fullStreamDecompression; } if (this.negotiationType == null) { this.negotiationType = config.negotiationType; } this.security.copyDefaultsFrom(config.security); }
java
public void copyDefaultsFrom(final GrpcChannelProperties config) { if (this == config) { return; } if (this.address == null) { this.address = config.address; } if (this.defaultLoadBalancingPolicy == null) { this.defaultLoadBalancingPolicy = config.defaultLoadBalancingPolicy; } if (this.enableKeepAlive == null) { this.enableKeepAlive = config.enableKeepAlive; } if (this.keepAliveTime == null) { this.keepAliveTime = config.keepAliveTime; } if (this.keepAliveTimeout == null) { this.keepAliveTimeout = config.keepAliveTimeout; } if (this.keepAliveWithoutCalls == null) { this.keepAliveWithoutCalls = config.keepAliveWithoutCalls; } if (this.maxInboundMessageSize == null) { this.maxInboundMessageSize = config.maxInboundMessageSize; } if (this.fullStreamDecompression == null) { this.fullStreamDecompression = config.fullStreamDecompression; } if (this.negotiationType == null) { this.negotiationType = config.negotiationType; } this.security.copyDefaultsFrom(config.security); }
[ "public", "void", "copyDefaultsFrom", "(", "final", "GrpcChannelProperties", "config", ")", "{", "if", "(", "this", "==", "config", ")", "{", "return", ";", "}", "if", "(", "this", ".", "address", "==", "null", ")", "{", "this", ".", "address", "=", "config", ".", "address", ";", "}", "if", "(", "this", ".", "defaultLoadBalancingPolicy", "==", "null", ")", "{", "this", ".", "defaultLoadBalancingPolicy", "=", "config", ".", "defaultLoadBalancingPolicy", ";", "}", "if", "(", "this", ".", "enableKeepAlive", "==", "null", ")", "{", "this", ".", "enableKeepAlive", "=", "config", ".", "enableKeepAlive", ";", "}", "if", "(", "this", ".", "keepAliveTime", "==", "null", ")", "{", "this", ".", "keepAliveTime", "=", "config", ".", "keepAliveTime", ";", "}", "if", "(", "this", ".", "keepAliveTimeout", "==", "null", ")", "{", "this", ".", "keepAliveTimeout", "=", "config", ".", "keepAliveTimeout", ";", "}", "if", "(", "this", ".", "keepAliveWithoutCalls", "==", "null", ")", "{", "this", ".", "keepAliveWithoutCalls", "=", "config", ".", "keepAliveWithoutCalls", ";", "}", "if", "(", "this", ".", "maxInboundMessageSize", "==", "null", ")", "{", "this", ".", "maxInboundMessageSize", "=", "config", ".", "maxInboundMessageSize", ";", "}", "if", "(", "this", ".", "fullStreamDecompression", "==", "null", ")", "{", "this", ".", "fullStreamDecompression", "=", "config", ".", "fullStreamDecompression", ";", "}", "if", "(", "this", ".", "negotiationType", "==", "null", ")", "{", "this", ".", "negotiationType", "=", "config", ".", "negotiationType", ";", "}", "this", ".", "security", ".", "copyDefaultsFrom", "(", "config", ".", "security", ")", ";", "}" ]
Copies the defaults from the given configuration. Values are considered "default" if they are null. Please note that the getters might return fallback values instead. @param config The config to copy the defaults from.
[ "Copies", "the", "defaults", "from", "the", "given", "configuration", ".", "Values", "are", "considered", "default", "if", "they", "are", "null", ".", "Please", "note", "that", "the", "getters", "might", "return", "fallback", "values", "instead", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/config/GrpcChannelProperties.java#L380-L412
15,786
yidongnan/grpc-spring-boot-starter
grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/security/check/ManualGrpcSecurityMetadataSource.java
ManualGrpcSecurityMetadataSource.set
public ManualGrpcSecurityMetadataSource set(final ServiceDescriptor service, final AccessPredicate predicate) { requireNonNull(service, "service"); final Collection<ConfigAttribute> wrappedPredicate = wrap(predicate); for (final MethodDescriptor<?, ?> method : service.getMethods()) { this.accessMap.put(method, wrappedPredicate); } return this; }
java
public ManualGrpcSecurityMetadataSource set(final ServiceDescriptor service, final AccessPredicate predicate) { requireNonNull(service, "service"); final Collection<ConfigAttribute> wrappedPredicate = wrap(predicate); for (final MethodDescriptor<?, ?> method : service.getMethods()) { this.accessMap.put(method, wrappedPredicate); } return this; }
[ "public", "ManualGrpcSecurityMetadataSource", "set", "(", "final", "ServiceDescriptor", "service", ",", "final", "AccessPredicate", "predicate", ")", "{", "requireNonNull", "(", "service", ",", "\"service\"", ")", ";", "final", "Collection", "<", "ConfigAttribute", ">", "wrappedPredicate", "=", "wrap", "(", "predicate", ")", ";", "for", "(", "final", "MethodDescriptor", "<", "?", ",", "?", ">", "method", ":", "service", ".", "getMethods", "(", ")", ")", "{", "this", ".", "accessMap", ".", "put", "(", "method", ",", "wrappedPredicate", ")", ";", "}", "return", "this", ";", "}" ]
Set the given access predicate for the all methods of the given service. This will replace previously set predicates. @param service The service to protect with a custom check. @param predicate The predicate used to check the {@link Authentication}. @return This instance for chaining. @see #setDefault(AccessPredicate)
[ "Set", "the", "given", "access", "predicate", "for", "the", "all", "methods", "of", "the", "given", "service", ".", "This", "will", "replace", "previously", "set", "predicates", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/security/check/ManualGrpcSecurityMetadataSource.java#L70-L77
15,787
yidongnan/grpc-spring-boot-starter
grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/security/check/ManualGrpcSecurityMetadataSource.java
ManualGrpcSecurityMetadataSource.remove
public ManualGrpcSecurityMetadataSource remove(final ServiceDescriptor service) { requireNonNull(service, "service"); for (final MethodDescriptor<?, ?> method : service.getMethods()) { this.accessMap.remove(method); } return this; }
java
public ManualGrpcSecurityMetadataSource remove(final ServiceDescriptor service) { requireNonNull(service, "service"); for (final MethodDescriptor<?, ?> method : service.getMethods()) { this.accessMap.remove(method); } return this; }
[ "public", "ManualGrpcSecurityMetadataSource", "remove", "(", "final", "ServiceDescriptor", "service", ")", "{", "requireNonNull", "(", "service", ",", "\"service\"", ")", ";", "for", "(", "final", "MethodDescriptor", "<", "?", ",", "?", ">", "method", ":", "service", ".", "getMethods", "(", ")", ")", "{", "this", ".", "accessMap", ".", "remove", "(", "method", ")", ";", "}", "return", "this", ";", "}" ]
Removes all access predicates for the all methods of the given service. After that, the default will be used for those methods. @param service The service to protect with only the default. @return This instance for chaining. @see #setDefault(AccessPredicate)
[ "Removes", "all", "access", "predicates", "for", "the", "all", "methods", "of", "the", "given", "service", ".", "After", "that", "the", "default", "will", "be", "used", "for", "those", "methods", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/security/check/ManualGrpcSecurityMetadataSource.java#L87-L93
15,788
yidongnan/grpc-spring-boot-starter
grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/security/check/ManualGrpcSecurityMetadataSource.java
ManualGrpcSecurityMetadataSource.set
public ManualGrpcSecurityMetadataSource set(final MethodDescriptor<?, ?> method, final AccessPredicate predicate) { requireNonNull(method, "method"); this.accessMap.put(method, wrap(predicate)); return this; }
java
public ManualGrpcSecurityMetadataSource set(final MethodDescriptor<?, ?> method, final AccessPredicate predicate) { requireNonNull(method, "method"); this.accessMap.put(method, wrap(predicate)); return this; }
[ "public", "ManualGrpcSecurityMetadataSource", "set", "(", "final", "MethodDescriptor", "<", "?", ",", "?", ">", "method", ",", "final", "AccessPredicate", "predicate", ")", "{", "requireNonNull", "(", "method", ",", "\"method\"", ")", ";", "this", ".", "accessMap", ".", "put", "(", "method", ",", "wrap", "(", "predicate", ")", ")", ";", "return", "this", ";", "}" ]
Set the given access predicate for the given method. This will replace previously set predicates. @param method The method to protect with a custom check. @param predicate The predicate used to check the {@link Authentication}. @return This instance for chaining. @see #setDefault(AccessPredicate)
[ "Set", "the", "given", "access", "predicate", "for", "the", "given", "method", ".", "This", "will", "replace", "previously", "set", "predicates", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/security/check/ManualGrpcSecurityMetadataSource.java#L103-L107
15,789
yidongnan/grpc-spring-boot-starter
grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/security/check/ManualGrpcSecurityMetadataSource.java
ManualGrpcSecurityMetadataSource.wrap
private Collection<ConfigAttribute> wrap(final AccessPredicate predicate) { requireNonNull(predicate, "predicate"); if (predicate == AccessPredicates.PERMIT_ALL) { return of(); // Empty collection => public invocation } return of(new AccessPredicateConfigAttribute(predicate)); }
java
private Collection<ConfigAttribute> wrap(final AccessPredicate predicate) { requireNonNull(predicate, "predicate"); if (predicate == AccessPredicates.PERMIT_ALL) { return of(); // Empty collection => public invocation } return of(new AccessPredicateConfigAttribute(predicate)); }
[ "private", "Collection", "<", "ConfigAttribute", ">", "wrap", "(", "final", "AccessPredicate", "predicate", ")", "{", "requireNonNull", "(", "predicate", ",", "\"predicate\"", ")", ";", "if", "(", "predicate", "==", "AccessPredicates", ".", "PERMIT_ALL", ")", "{", "return", "of", "(", ")", ";", "// Empty collection => public invocation", "}", "return", "of", "(", "new", "AccessPredicateConfigAttribute", "(", "predicate", ")", ")", ";", "}" ]
Wraps the given predicate in a configuration attribute and an immutable collection. @param predicate The predicate to wrap. @return The newly created list with the given predicate.
[ "Wraps", "the", "given", "predicate", "in", "a", "configuration", "attribute", "and", "an", "immutable", "collection", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/security/check/ManualGrpcSecurityMetadataSource.java#L139-L145
15,790
yidongnan/grpc-spring-boot-starter
grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/serverfactory/AbstractGrpcServerFactory.java
AbstractGrpcServerFactory.configureServices
protected void configureServices(final T builder) { // support health check if (this.properties.isHealthServiceEnabled()) { builder.addService(this.healthStatusManager.getHealthService()); } if (this.properties.isReflectionServiceEnabled()) { builder.addService(ProtoReflectionService.newInstance()); } for (final GrpcServiceDefinition service : this.serviceList) { final String serviceName = service.getDefinition().getServiceDescriptor().getName(); log.info("Registered gRPC service: " + serviceName + ", bean: " + service.getBeanName() + ", class: " + service.getBeanClazz().getName()); builder.addService(service.getDefinition()); this.healthStatusManager.setStatus(serviceName, HealthCheckResponse.ServingStatus.SERVING); } }
java
protected void configureServices(final T builder) { // support health check if (this.properties.isHealthServiceEnabled()) { builder.addService(this.healthStatusManager.getHealthService()); } if (this.properties.isReflectionServiceEnabled()) { builder.addService(ProtoReflectionService.newInstance()); } for (final GrpcServiceDefinition service : this.serviceList) { final String serviceName = service.getDefinition().getServiceDescriptor().getName(); log.info("Registered gRPC service: " + serviceName + ", bean: " + service.getBeanName() + ", class: " + service.getBeanClazz().getName()); builder.addService(service.getDefinition()); this.healthStatusManager.setStatus(serviceName, HealthCheckResponse.ServingStatus.SERVING); } }
[ "protected", "void", "configureServices", "(", "final", "T", "builder", ")", "{", "// support health check", "if", "(", "this", ".", "properties", ".", "isHealthServiceEnabled", "(", ")", ")", "{", "builder", ".", "addService", "(", "this", ".", "healthStatusManager", ".", "getHealthService", "(", ")", ")", ";", "}", "if", "(", "this", ".", "properties", ".", "isReflectionServiceEnabled", "(", ")", ")", "{", "builder", ".", "addService", "(", "ProtoReflectionService", ".", "newInstance", "(", ")", ")", ";", "}", "for", "(", "final", "GrpcServiceDefinition", "service", ":", "this", ".", "serviceList", ")", "{", "final", "String", "serviceName", "=", "service", ".", "getDefinition", "(", ")", ".", "getServiceDescriptor", "(", ")", ".", "getName", "(", ")", ";", "log", ".", "info", "(", "\"Registered gRPC service: \"", "+", "serviceName", "+", "\", bean: \"", "+", "service", ".", "getBeanName", "(", ")", "+", "\", class: \"", "+", "service", ".", "getBeanClazz", "(", ")", ".", "getName", "(", ")", ")", ";", "builder", ".", "addService", "(", "service", ".", "getDefinition", "(", ")", ")", ";", "this", ".", "healthStatusManager", ".", "setStatus", "(", "serviceName", ",", "HealthCheckResponse", ".", "ServingStatus", ".", "SERVING", ")", ";", "}", "}" ]
Configures the services that should be served by the server. @param builder The server builder to configure.
[ "Configures", "the", "services", "that", "should", "be", "served", "by", "the", "server", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/serverfactory/AbstractGrpcServerFactory.java#L104-L120
15,791
yidongnan/grpc-spring-boot-starter
grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/serverfactory/AbstractGrpcServerFactory.java
AbstractGrpcServerFactory.configureLimits
protected void configureLimits(final T builder) { final Integer maxInboundMessageSize = this.properties.getMaxInboundMessageSize(); if (maxInboundMessageSize != null) { builder.maxInboundMessageSize(maxInboundMessageSize); } }
java
protected void configureLimits(final T builder) { final Integer maxInboundMessageSize = this.properties.getMaxInboundMessageSize(); if (maxInboundMessageSize != null) { builder.maxInboundMessageSize(maxInboundMessageSize); } }
[ "protected", "void", "configureLimits", "(", "final", "T", "builder", ")", "{", "final", "Integer", "maxInboundMessageSize", "=", "this", ".", "properties", ".", "getMaxInboundMessageSize", "(", ")", ";", "if", "(", "maxInboundMessageSize", "!=", "null", ")", "{", "builder", ".", "maxInboundMessageSize", "(", "maxInboundMessageSize", ")", ";", "}", "}" ]
Configures limits such as max message sizes that should be used by the server. @param builder The server builder to configure.
[ "Configures", "limits", "such", "as", "max", "message", "sizes", "that", "should", "be", "used", "by", "the", "server", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/serverfactory/AbstractGrpcServerFactory.java#L172-L177
15,792
yidongnan/grpc-spring-boot-starter
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/channelfactory/AbstractChannelFactory.java
AbstractChannelFactory.configure
protected void configure(final T builder, final String name) { configureKeepAlive(builder, name); configureSecurity(builder, name); configureLimits(builder, name); configureCompression(builder, name); for (final GrpcChannelConfigurer channelConfigurer : this.channelConfigurers) { channelConfigurer.accept(builder, name); } }
java
protected void configure(final T builder, final String name) { configureKeepAlive(builder, name); configureSecurity(builder, name); configureLimits(builder, name); configureCompression(builder, name); for (final GrpcChannelConfigurer channelConfigurer : this.channelConfigurers) { channelConfigurer.accept(builder, name); } }
[ "protected", "void", "configure", "(", "final", "T", "builder", ",", "final", "String", "name", ")", "{", "configureKeepAlive", "(", "builder", ",", "name", ")", ";", "configureSecurity", "(", "builder", ",", "name", ")", ";", "configureLimits", "(", "builder", ",", "name", ")", ";", "configureCompression", "(", "builder", ",", "name", ")", ";", "for", "(", "final", "GrpcChannelConfigurer", "channelConfigurer", ":", "this", ".", "channelConfigurers", ")", "{", "channelConfigurer", ".", "accept", "(", "builder", ",", "name", ")", ";", "}", "}" ]
Configures the given channel builder. This method can be overwritten to add features that are not yet supported by this library. @param builder The channel builder to configure. @param name The name of the client to configure.
[ "Configures", "the", "given", "channel", "builder", ".", "This", "method", "can", "be", "overwritten", "to", "add", "features", "that", "are", "not", "yet", "supported", "by", "this", "library", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/channelfactory/AbstractChannelFactory.java#L152-L160
15,793
yidongnan/grpc-spring-boot-starter
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/channelfactory/AbstractChannelFactory.java
AbstractChannelFactory.configureKeepAlive
protected void configureKeepAlive(final T builder, final String name) { final GrpcChannelProperties properties = getPropertiesFor(name); if (properties.isEnableKeepAlive()) { builder.keepAliveTime(properties.getKeepAliveTime().toNanos(), TimeUnit.NANOSECONDS) .keepAliveTimeout(properties.getKeepAliveTimeout().toNanos(), TimeUnit.NANOSECONDS) .keepAliveWithoutCalls(properties.isKeepAliveWithoutCalls()); } }
java
protected void configureKeepAlive(final T builder, final String name) { final GrpcChannelProperties properties = getPropertiesFor(name); if (properties.isEnableKeepAlive()) { builder.keepAliveTime(properties.getKeepAliveTime().toNanos(), TimeUnit.NANOSECONDS) .keepAliveTimeout(properties.getKeepAliveTimeout().toNanos(), TimeUnit.NANOSECONDS) .keepAliveWithoutCalls(properties.isKeepAliveWithoutCalls()); } }
[ "protected", "void", "configureKeepAlive", "(", "final", "T", "builder", ",", "final", "String", "name", ")", "{", "final", "GrpcChannelProperties", "properties", "=", "getPropertiesFor", "(", "name", ")", ";", "if", "(", "properties", ".", "isEnableKeepAlive", "(", ")", ")", "{", "builder", ".", "keepAliveTime", "(", "properties", ".", "getKeepAliveTime", "(", ")", ".", "toNanos", "(", ")", ",", "TimeUnit", ".", "NANOSECONDS", ")", ".", "keepAliveTimeout", "(", "properties", ".", "getKeepAliveTimeout", "(", ")", ".", "toNanos", "(", ")", ",", "TimeUnit", ".", "NANOSECONDS", ")", ".", "keepAliveWithoutCalls", "(", "properties", ".", "isKeepAliveWithoutCalls", "(", ")", ")", ";", "}", "}" ]
Configures the keep alive options that should be used by the channel. @param builder The channel builder to configure. @param name The name of the client to configure.
[ "Configures", "the", "keep", "alive", "options", "that", "should", "be", "used", "by", "the", "channel", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/channelfactory/AbstractChannelFactory.java#L168-L175
15,794
yidongnan/grpc-spring-boot-starter
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/channelfactory/AbstractChannelFactory.java
AbstractChannelFactory.configureSecurity
protected void configureSecurity(final T builder, final String name) { final GrpcChannelProperties properties = getPropertiesFor(name); final Security security = properties.getSecurity(); if (properties.getNegotiationType() != NegotiationType.TLS // non-default || isNonNullAndNonBlank(security.getAuthorityOverride()) || isNonNullAndNonBlank(security.getCertificateChainPath()) || isNonNullAndNonBlank(security.getPrivateKeyPath()) || isNonNullAndNonBlank(security.getTrustCertCollectionPath())) { throw new IllegalStateException( "Security is configured but this implementation does not support security!"); } }
java
protected void configureSecurity(final T builder, final String name) { final GrpcChannelProperties properties = getPropertiesFor(name); final Security security = properties.getSecurity(); if (properties.getNegotiationType() != NegotiationType.TLS // non-default || isNonNullAndNonBlank(security.getAuthorityOverride()) || isNonNullAndNonBlank(security.getCertificateChainPath()) || isNonNullAndNonBlank(security.getPrivateKeyPath()) || isNonNullAndNonBlank(security.getTrustCertCollectionPath())) { throw new IllegalStateException( "Security is configured but this implementation does not support security!"); } }
[ "protected", "void", "configureSecurity", "(", "final", "T", "builder", ",", "final", "String", "name", ")", "{", "final", "GrpcChannelProperties", "properties", "=", "getPropertiesFor", "(", "name", ")", ";", "final", "Security", "security", "=", "properties", ".", "getSecurity", "(", ")", ";", "if", "(", "properties", ".", "getNegotiationType", "(", ")", "!=", "NegotiationType", ".", "TLS", "// non-default", "||", "isNonNullAndNonBlank", "(", "security", ".", "getAuthorityOverride", "(", ")", ")", "||", "isNonNullAndNonBlank", "(", "security", ".", "getCertificateChainPath", "(", ")", ")", "||", "isNonNullAndNonBlank", "(", "security", ".", "getPrivateKeyPath", "(", ")", ")", "||", "isNonNullAndNonBlank", "(", "security", ".", "getTrustCertCollectionPath", "(", ")", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Security is configured but this implementation does not support security!\"", ")", ";", "}", "}" ]
Configures the security options that should be used by the channel. @param builder The channel builder to configure. @param name The name of the client to configure.
[ "Configures", "the", "security", "options", "that", "should", "be", "used", "by", "the", "channel", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/channelfactory/AbstractChannelFactory.java#L183-L195
15,795
yidongnan/grpc-spring-boot-starter
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/channelfactory/AbstractChannelFactory.java
AbstractChannelFactory.configureLimits
protected void configureLimits(final T builder, final String name) { final GrpcChannelProperties properties = getPropertiesFor(name); final Integer maxInboundMessageSize = properties.getMaxInboundMessageSize(); if (maxInboundMessageSize != null) { builder.maxInboundMessageSize(maxInboundMessageSize); } }
java
protected void configureLimits(final T builder, final String name) { final GrpcChannelProperties properties = getPropertiesFor(name); final Integer maxInboundMessageSize = properties.getMaxInboundMessageSize(); if (maxInboundMessageSize != null) { builder.maxInboundMessageSize(maxInboundMessageSize); } }
[ "protected", "void", "configureLimits", "(", "final", "T", "builder", ",", "final", "String", "name", ")", "{", "final", "GrpcChannelProperties", "properties", "=", "getPropertiesFor", "(", "name", ")", ";", "final", "Integer", "maxInboundMessageSize", "=", "properties", ".", "getMaxInboundMessageSize", "(", ")", ";", "if", "(", "maxInboundMessageSize", "!=", "null", ")", "{", "builder", ".", "maxInboundMessageSize", "(", "maxInboundMessageSize", ")", ";", "}", "}" ]
Configures limits such as max message sizes that should be used by the channel. @param builder The channel builder to configure. @param name The name of the client to configure.
[ "Configures", "limits", "such", "as", "max", "message", "sizes", "that", "should", "be", "used", "by", "the", "channel", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/channelfactory/AbstractChannelFactory.java#L230-L236
15,796
yidongnan/grpc-spring-boot-starter
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/channelfactory/AbstractChannelFactory.java
AbstractChannelFactory.configureCompression
protected void configureCompression(final T builder, final String name) { final GrpcChannelProperties properties = getPropertiesFor(name); if (properties.isFullStreamDecompression()) { builder.enableFullStreamDecompression(); } }
java
protected void configureCompression(final T builder, final String name) { final GrpcChannelProperties properties = getPropertiesFor(name); if (properties.isFullStreamDecompression()) { builder.enableFullStreamDecompression(); } }
[ "protected", "void", "configureCompression", "(", "final", "T", "builder", ",", "final", "String", "name", ")", "{", "final", "GrpcChannelProperties", "properties", "=", "getPropertiesFor", "(", "name", ")", ";", "if", "(", "properties", ".", "isFullStreamDecompression", "(", ")", ")", "{", "builder", ".", "enableFullStreamDecompression", "(", ")", ";", "}", "}" ]
Configures the compression options that should be used by the channel. @param builder The channel builder to configure. @param name The name of the client to configure.
[ "Configures", "the", "compression", "options", "that", "should", "be", "used", "by", "the", "channel", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/channelfactory/AbstractChannelFactory.java#L244-L249
15,797
yidongnan/grpc-spring-boot-starter
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/channelfactory/AbstractChannelFactory.java
AbstractChannelFactory.close
@Override @PreDestroy public synchronized void close() { if (this.shutdown) { return; } this.shutdown = true; for (final ManagedChannel channel : this.channels.values()) { channel.shutdown(); } try { final long waitLimit = System.currentTimeMillis() + 60_000; // wait 60 seconds at max for (final ManagedChannel channel : this.channels.values()) { int i = 0; do { log.debug("Awaiting channel shutdown: {} ({}s)", channel, i++); } while (System.currentTimeMillis() < waitLimit && !channel.awaitTermination(1, TimeUnit.SECONDS)); } } catch (final InterruptedException e) { Thread.currentThread().interrupt(); log.debug("We got interrupted - Speeding up shutdown process"); } finally { for (final ManagedChannel channel : this.channels.values()) { if (!channel.isTerminated()) { log.debug("Channel not terminated yet - force shutdown now: {} ", channel); channel.shutdownNow(); } } } final int channelCount = this.channels.size(); this.channels.clear(); log.debug("GrpcCannelFactory closed (including {} channels)", channelCount); }
java
@Override @PreDestroy public synchronized void close() { if (this.shutdown) { return; } this.shutdown = true; for (final ManagedChannel channel : this.channels.values()) { channel.shutdown(); } try { final long waitLimit = System.currentTimeMillis() + 60_000; // wait 60 seconds at max for (final ManagedChannel channel : this.channels.values()) { int i = 0; do { log.debug("Awaiting channel shutdown: {} ({}s)", channel, i++); } while (System.currentTimeMillis() < waitLimit && !channel.awaitTermination(1, TimeUnit.SECONDS)); } } catch (final InterruptedException e) { Thread.currentThread().interrupt(); log.debug("We got interrupted - Speeding up shutdown process"); } finally { for (final ManagedChannel channel : this.channels.values()) { if (!channel.isTerminated()) { log.debug("Channel not terminated yet - force shutdown now: {} ", channel); channel.shutdownNow(); } } } final int channelCount = this.channels.size(); this.channels.clear(); log.debug("GrpcCannelFactory closed (including {} channels)", channelCount); }
[ "@", "Override", "@", "PreDestroy", "public", "synchronized", "void", "close", "(", ")", "{", "if", "(", "this", ".", "shutdown", ")", "{", "return", ";", "}", "this", ".", "shutdown", "=", "true", ";", "for", "(", "final", "ManagedChannel", "channel", ":", "this", ".", "channels", ".", "values", "(", ")", ")", "{", "channel", ".", "shutdown", "(", ")", ";", "}", "try", "{", "final", "long", "waitLimit", "=", "System", ".", "currentTimeMillis", "(", ")", "+", "60_000", ";", "// wait 60 seconds at max", "for", "(", "final", "ManagedChannel", "channel", ":", "this", ".", "channels", ".", "values", "(", ")", ")", "{", "int", "i", "=", "0", ";", "do", "{", "log", ".", "debug", "(", "\"Awaiting channel shutdown: {} ({}s)\"", ",", "channel", ",", "i", "++", ")", ";", "}", "while", "(", "System", ".", "currentTimeMillis", "(", ")", "<", "waitLimit", "&&", "!", "channel", ".", "awaitTermination", "(", "1", ",", "TimeUnit", ".", "SECONDS", ")", ")", ";", "}", "}", "catch", "(", "final", "InterruptedException", "e", ")", "{", "Thread", ".", "currentThread", "(", ")", ".", "interrupt", "(", ")", ";", "log", ".", "debug", "(", "\"We got interrupted - Speeding up shutdown process\"", ")", ";", "}", "finally", "{", "for", "(", "final", "ManagedChannel", "channel", ":", "this", ".", "channels", ".", "values", "(", ")", ")", "{", "if", "(", "!", "channel", ".", "isTerminated", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Channel not terminated yet - force shutdown now: {} \"", ",", "channel", ")", ";", "channel", ".", "shutdownNow", "(", ")", ";", "}", "}", "}", "final", "int", "channelCount", "=", "this", ".", "channels", ".", "size", "(", ")", ";", "this", ".", "channels", ".", "clear", "(", ")", ";", "log", ".", "debug", "(", "\"GrpcCannelFactory closed (including {} channels)\"", ",", "channelCount", ")", ";", "}" ]
Closes this channel factory and the channels created by this instance. The shutdown happens in two phases, first an orderly shutdown is initiated on all channels and then the method waits for all channels to terminate. If the channels don't have terminated after 60 seconds then they will be forcefully shutdown.
[ "Closes", "this", "channel", "factory", "and", "the", "channels", "created", "by", "this", "instance", ".", "The", "shutdown", "happens", "in", "two", "phases", "first", "an", "orderly", "shutdown", "is", "initiated", "on", "all", "channels", "and", "then", "the", "method", "waits", "for", "all", "channels", "to", "terminate", ".", "If", "the", "channels", "don", "t", "have", "terminated", "after", "60", "seconds", "then", "they", "will", "be", "forcefully", "shutdown", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/channelfactory/AbstractChannelFactory.java#L256-L288
15,798
yidongnan/grpc-spring-boot-starter
grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/serverfactory/GrpcServerLifecycle.java
GrpcServerLifecycle.createAndStartGrpcServer
protected void createAndStartGrpcServer() throws IOException { final Server localServer = this.server; if (localServer == null) { this.server = this.factory.createServer(); this.server.start(); log.info("gRPC Server started, listening on address: " + this.factory.getAddress() + ", port: " + this.factory.getPort()); final Thread awaitThread = new Thread("container-" + (serverCounter.incrementAndGet())) { @Override public void run() { try { GrpcServerLifecycle.this.server.awaitTermination(); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); } } }; awaitThread.setDaemon(false); awaitThread.start(); } }
java
protected void createAndStartGrpcServer() throws IOException { final Server localServer = this.server; if (localServer == null) { this.server = this.factory.createServer(); this.server.start(); log.info("gRPC Server started, listening on address: " + this.factory.getAddress() + ", port: " + this.factory.getPort()); final Thread awaitThread = new Thread("container-" + (serverCounter.incrementAndGet())) { @Override public void run() { try { GrpcServerLifecycle.this.server.awaitTermination(); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); } } }; awaitThread.setDaemon(false); awaitThread.start(); } }
[ "protected", "void", "createAndStartGrpcServer", "(", ")", "throws", "IOException", "{", "final", "Server", "localServer", "=", "this", ".", "server", ";", "if", "(", "localServer", "==", "null", ")", "{", "this", ".", "server", "=", "this", ".", "factory", ".", "createServer", "(", ")", ";", "this", ".", "server", ".", "start", "(", ")", ";", "log", ".", "info", "(", "\"gRPC Server started, listening on address: \"", "+", "this", ".", "factory", ".", "getAddress", "(", ")", "+", "\", port: \"", "+", "this", ".", "factory", ".", "getPort", "(", ")", ")", ";", "final", "Thread", "awaitThread", "=", "new", "Thread", "(", "\"container-\"", "+", "(", "serverCounter", ".", "incrementAndGet", "(", ")", ")", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "try", "{", "GrpcServerLifecycle", ".", "this", ".", "server", ".", "awaitTermination", "(", ")", ";", "}", "catch", "(", "final", "InterruptedException", "e", ")", "{", "Thread", ".", "currentThread", "(", ")", ".", "interrupt", "(", ")", ";", "}", "}", "}", ";", "awaitThread", ".", "setDaemon", "(", "false", ")", ";", "awaitThread", ".", "start", "(", ")", ";", "}", "}" ]
Creates and starts the grpc server. @throws IOException If the server is unable to bind the port.
[ "Creates", "and", "starts", "the", "grpc", "server", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/serverfactory/GrpcServerLifecycle.java#L86-L109
15,799
yidongnan/grpc-spring-boot-starter
grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/serverfactory/GrpcServerLifecycle.java
GrpcServerLifecycle.stopAndReleaseGrpcServer
protected void stopAndReleaseGrpcServer() { factory.destroy(); Server localServer = this.server; if (localServer != null) { localServer.shutdown(); this.server = null; log.info("gRPC server shutdown."); } }
java
protected void stopAndReleaseGrpcServer() { factory.destroy(); Server localServer = this.server; if (localServer != null) { localServer.shutdown(); this.server = null; log.info("gRPC server shutdown."); } }
[ "protected", "void", "stopAndReleaseGrpcServer", "(", ")", "{", "factory", ".", "destroy", "(", ")", ";", "Server", "localServer", "=", "this", ".", "server", ";", "if", "(", "localServer", "!=", "null", ")", "{", "localServer", ".", "shutdown", "(", ")", ";", "this", ".", "server", "=", "null", ";", "log", ".", "info", "(", "\"gRPC server shutdown.\"", ")", ";", "}", "}" ]
Initiates an orderly shutdown of the grpc server and releases the references to the server. This call does not wait for the server to be completely shut down.
[ "Initiates", "an", "orderly", "shutdown", "of", "the", "grpc", "server", "and", "releases", "the", "references", "to", "the", "server", ".", "This", "call", "does", "not", "wait", "for", "the", "server", "to", "be", "completely", "shut", "down", "." ]
07f8853cfafc9707584f2371aff012e590217b85
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/serverfactory/GrpcServerLifecycle.java#L115-L123