-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
offers.getNextToken() has been nul #275
Comments
Hello,
Is this a new issue on an Ice instance that has been running fine so far ?
Or is this a new Ice instance you are trying to setup ?
Nicolas
…--
Nicolas Fonrose | Teevity | Founder
+33.6.61.35.43.31
https://teevity.com - Cloud Costs Analytics built on NetflixOSS
twitter - @nfonrose / @Teevity
On Fri, Nov 3, 2017 at 9:15 AM, blair_chen ***@***.***> wrote:
`private void pollAPI() throws Exception {
long currentTime = new DateMidnight().getMillis();
DescribeReservedInstancesOfferingsRequest req = new DescribeReservedInstancesOfferingsRequest()
.withFilters(new com.amazonaws.services.ec2.model.Filter().withName("marketplace").withValues("false"));
String token = null;
boolean hasNewPrice = false;
AmazonEC2Client ec2Client = new AmazonEC2Client(AwsUtils.awsCredentialsProvider, AwsUtils.clientConfig);
for (Region region: Region.getAllRegions()) {
// GovCloud uses different credentials than standard AWS, so you would need two separate
// sets of credentials if you wanted to poll for RIs in both environments. For now, we
// just ignore GovCloud here in order to prevent AuthFailure errors.
if (region == Region.US_GOV_WEST_1) {
continue;
}
ec2Client.setEndpoint("ec2." + region.name + ".amazonaws.com");
do {
if (!StringUtils.isEmpty(token))
req.setNextToken(token);
DescribeReservedInstancesOfferingsResult offers = ec2Client.describeReservedInstancesOfferings(req);
token = offers.getNextToken();
for (ReservedInstancesOffering offer: offers.getReservedInstancesOfferings()) {
logger.info("offers list size,"+ offers.getReservedInstancesOfferings().size());
if (offer.getProductDescription().indexOf("Amazon VPC") >= 0)
continue;
// Ignore Region-Wide RIs
if (offer.getAvailabilityZone() == null)
continue;
ReservationUtilization utilization = ReservationUtilization.get(offer.getOfferingType());
Ec2InstanceReservationPrice.ReservationPeriod term = offer.getDuration() / 24 / 3600 > 366 ?
Ec2InstanceReservationPrice.ReservationPeriod.threeyear : Ec2InstanceReservationPrice.ReservationPeriod.oneyear;
if (term != this.term)
continue;
double hourly = offer.getUsagePrice();
if (hourly <= 0) {
for (RecurringCharge recurringCharge: offer.getRecurringCharges()) {
if (recurringCharge.getFrequency().equals("Hourly")) {
hourly = recurringCharge.getAmount();
break;
}
}
}
UsageType usageType = getUsageType(offer.getInstanceType(), offer.getProductDescription());
// Unknown Zone
if (Zone.getZone(offer.getAvailabilityZone()) == null) {
logger.error("No Zone for " + offer.getAvailabilityZone());
} else {
hasNewPrice = setPrice(utilization, currentTime, Zone.getZone(offer.getAvailabilityZone()).region, usageType,
offer.getFixedPrice(), hourly) || hasNewPrice;
logger.info("Setting RI price for " + Zone.getZone(offer.getAvailabilityZone()).region + " " + utilization + " " + usageType + " " + offer.getFixedPrice() + " " + hourly);
}
}
} while (!StringUtils.isEmpty(token));
}
ec2Client.shutdown();
if (hasNewPrice) {
for (ReservationUtilization utilization: files.keySet()) {
File file = files.get(utilization);
DataOutputStream out = new DataOutputStream(new FileOutputStream(file));
try {
Serializer.serialize(out, this.ec2InstanceReservationPrices.get(utilization));
AwsUtils.upload(config.workS3BucketName, config.workS3BucketPrefix, file);
}
finally {
out.close();
}
}
}
}`
token = offers.getNextToken(); has been null, and then the cycle of death
Why not take token
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#275>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACUpRQirzzALWUORx9V2XRzE8it0LN1ks5sysuGgaJpZM4QQw1b>
.
|
@nfonrose A new example and i use the latest code installed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
`private void pollAPI() throws Exception {
long currentTime = new DateMidnight().getMillis();
token = offers.getNextToken(); has been null, and then the cycle of death
Why not take token
The text was updated successfully, but these errors were encountered: