public class EcsRoleCredentialProvider extends Object implements Provider
Follows the Provider CQS contract:
isExpired() / retrieve() are pure reads.refresh() is the only method that mutates state.Intended to be wrapped in a CredentialProvider, which serializes
refresh through a ReadWriteLock and
guarantees the isExpired → refresh → retrieve sequence. Direct use
(without wrapping) is not a supported mode.
| Constructor and Description |
|---|
EcsRoleCredentialProvider(String roleName) |
EcsRoleCredentialProvider(String roleName,
int connectTimeoutMs,
int readTimeoutMs,
int maxRetries,
int retryIntervalMs,
int expireBufferSeconds) |
| Modifier and Type | Method and Description |
|---|---|
static EcsRoleCredentialProvider |
create(String roleName) |
static boolean |
isDisabledByEnv()
Returns true when
BYTEPLUS_ECS_METADATA_DISABLED=true is set. |
boolean |
isExpired() |
void |
refresh() |
CredentialValue |
retrieve() |
void |
setConnectTimeoutMs(int connectTimeoutMs) |
void |
setExpireBufferSeconds(int expireBufferSeconds) |
void |
setMaxRetries(int maxRetries) |
void |
setReadTimeoutMs(int readTimeoutMs) |
void |
setRetryIntervalMs(int retryIntervalMs) |
public EcsRoleCredentialProvider(String roleName)
public EcsRoleCredentialProvider(String roleName, int connectTimeoutMs, int readTimeoutMs, int maxRetries, int retryIntervalMs, int expireBufferSeconds)
public static boolean isDisabledByEnv()
BYTEPLUS_ECS_METADATA_DISABLED=true is set.
Used by DefaultCredentialProvider to skip adding the IMDS step
to the chain, and by the constructor to fail fast on direct new.public static EcsRoleCredentialProvider create(String roleName)
public void setConnectTimeoutMs(int connectTimeoutMs)
public void setReadTimeoutMs(int readTimeoutMs)
public void setMaxRetries(int maxRetries)
public void setRetryIntervalMs(int retryIntervalMs)
public void setExpireBufferSeconds(int expireBufferSeconds)
public void refresh()
throws ApiException
refresh in interface ProviderApiExceptionpublic CredentialValue retrieve() throws ApiException
retrieve in interface ProviderApiExceptionCopyright © 2026. All rights reserved.