Pages

Showing posts with label one. Show all posts
Showing posts with label one. Show all posts

Wednesday, March 11, 2015

A One Two Punch for Getting Even More out of Google Apps APIs

Editor’s Note: Guest author Steve Ziegler is a senior architect at BetterCloud—Arun Nagarajan

FlashPanel, a leading enterprise-grade security and management application for Google Apps, makes use of many Google Apps APIs. Each API comes with its own set of rate-limiting quotas, network traffic behavior and response conditions. The challenge we face is to provide our customers with a stable, consistent experience despite these API behavior differences. Fortunately, Google has provided two simple, yet powerful tools to greatly increase our success rate and reliability.

Controlling Throttle Rates with Guava’s RateLimiter


Google Apps APIs operate with quota rates per second or per day. As such, the FlashPanel development team’s objective is to minimize total operation time of a parallelized set of API-intensive processes while avoiding running into Google’s API quota limits. To accomplish this, we can very easily set up a thread-safe RateLimiter for a specific rate per second for each rate restricted API:

final RateLimiter driveApiRateLimiter = RateLimiter.create(QUOTA_RATE_PER_SECOND);

The Guava RateLimiter allows us to attempt to acquire a permit based on the configured rate per second, block until available, and then take it when available, allowing execution.

To use it within the context of a method, we simply reference the rate limiter before making the API call:

public Result performDriveApiCall(driveApiRateLimiter, otherParams){
driveApiRateLimiter.acquire(); // blocks according to rate
// make API call...
}
This provides us with a very easy solution for rate limiting parallelized calls to the same APIs.

Reducing Impact of Network Traffic Issues Through Configured Backoffs


Occasionally, we experience additional network traffic issues despite enforcing rate limits. Google suggests that API clients use an exponential backoff strategy to handle this variety of error response. Typically this category of network issue resolves itself on its own after fractions of a second, but occasionally more time is needed. All we need to do to receive a successful API response is to simply retry the call some number of times, with the interval of time between retries growing exponentially.

Again, Google has made this easy through the Google HTTP Client for Java library’s ExponentialBackOff builder. This class allows us to configure the initial retry time interval, the exponential multiplier, the maximum total time to attempt to retry, and the maximum total time between retries. For example, we could configure a retry to span five minutes, growing with a factor of two, starting at a one second interval, and growing up to a maximum of one minute between retries. An API call with this configuration would retry with the following pattern in terms of seconds between retries:

1, 2, 4, 8, 16, 32, 60, 60, 60

If after this last retry, the API call still was not successful, the failed http response is returned. The code to configure such a strategy using the ExponentialBackOff.Builder reads as follows:

ExponentialBackOff backoff = new ExponentialBackOff.Builder()
.setInitialIntervalMillis(ONE_SECOND)
.setMultiplier(2.0)
.setMaxIntervalMillis(ONE_MINUTE)
.setMaxElapsedTimeMillis(FIVE_MINUTES)
.build();

One potential “gotcha” that we’ve seen is if we accidentally slam a particular API with many simultaneous API calls. In this event, not only would each of these API calls fail, but they would also schedule their retry strategy to occur simultaneously. All subsequent retries would end up firing simultaneously, causing the API calls to continue to fail due to excess per second volumes. The ExponentialBackoff class accounts for this by including a randomization factor within our retry logic that allows us to have each simultaneous API call stagger at different intervals.

For example, using our previous backoff but now with randomization, one API call may retry with these intervals:

1.04, 1.9, 4.23, 7.8, etc.

While a second API call would retry with something like these intervals:

.98, 2.04, 4.1, 8.15, etc.

With this randomization, we avoid API call sequencing collision, mitigating our chances of encountering quota related errors. To simply add this type of randomization, we append to our builder:

builder.setRandomizationFactor(RANDOMIZATION_FACTOR);

Once we have our exponential backoff strategy configured, the Google HTTP Client for Java library allows us to instantiate and assign an HttpBackOffUnsuccessfulResponseHandler to an HttpRequest as part of the request’s initialization:

private HttpBackOffUnsuccessfulResponseHandler handler = new HttpBackOffUnsuccessfulResponseHandler(backoff);

public void initialize(HttpRequest request){
request.setUnsuccessfulResponseHandler(handler);
}

Final Thoughts


By restricting our API calls using Google Guava’s easy-to-use RateLimiter, and by employing an exponential backoff strategy using the Google HTTP Client for Java library’s ExponentialBackOff, we are able to significantly reduce the amount of network traffic errors received by our Google Apps API calls, improving FlashPanel’s reliability and the overall user experience.

Steve is Senior Architect at BetterCloud, the makers of FlashPanel, the number one security and management application for Google Apps. Follow BetterCloud on Google+ at plus.google.com/+Bettercloud.

Posted by Greg Knoke, Googler
Read more »

Monday, March 2, 2015

The One Stop Learning Blog


ONE STOP LEARNING

"As I have progressed along my journey as an educator, I have come to better appreciate that teaching is about sharing—sharing what I have learned with others, including the public at large. This blog is my expression, my way of sharing my passion on the issue of teaching and learning, lifelong learning and education in general. It is also intended as a repository of resources related to teaching and learning. This is my humble attempt to put together useful links, articles, websites, presentations, videos, etc. in one place -- for my own reference and for those who are interested to learn more about teaching and learning...more"
- Professor Karim (Universiti Sains Malaysia)


I am always thrilled to discover new edublogs from educators in Higher Education in Malaysia passionate about sharing their learning discoveries and journeys. This blog by Prof. Karim has already been around since November 2010, so it is not totally new, but without doubt worth sharing here. Interestingly, we met during a workshop (National E-Learning Road Map) late last year (2010), and have since communicated through Twitter (@biopolimer) and e-mail, but ironically I didnt really discover his juicy blog until today.

As the One Stop Learning blog is also Prof. Karims own reference for learning discoveries on teaching and learning, means that his motivation to keep it going goes beyond hits and fame, which is important to keep it rolling until the world discovers this gem of a blog. Besides being self-motivated to share, it is always great to know that you have readers and people willing to challenge your ideas and thoughts. If he can keep it up (like now!), I am pretty sure that this blog will achieve just that as it explores and grows.

In short, why not visit...I shall say no more... just CLICK HERE :)
Read more »

Thursday, February 26, 2015

Schoolr All In One Online Research Tool

Schoolr: http://www.schoolr.com/
Schoolrs Blog: http://schoolr.wordpress.com/

This All-In-One search tool enables you to access several I-always-use sites (to find stuff) from one site, which currently include Reference.com family, Google, Wikipedia, Acrnonym Finder, Urban Dictionary, SparkNotes, NCSU, and unitconversion (Hopefully Answers.com and other juicy search sites could be added to the list soon). Since the search fields on Schoolr are linked directly to the sites they represent, it should not be difficult to add more (Though, information overload might kick-in).

Better yet, why not create a tool that enables us to add whatever tools we want to use for online researching (By the way the r in Schoolr stands for research), providing us the flexibility to access all our personal favorite juicy research tools from one site, saving us precious time. To add spice to it, we are able to see statistics on which research tools are mostly used, and who are using what, and the different combinations (on one site) used by anyone (according to the users preferences), including gurus like Joseph Hart, Jay Cross, and Jane Knight (who linked me to this tool). For information overload geeks like me, I would like to see all these research tools search at once, meaning that we only need to enter once (one entry field only, saving us more precious time) with checkboxes to the research tools (and the ability to add new checkboxes as we discover), and then the window will split into 2,4,6, 8 or more smaller windows (depending upon your selected checkboxes), enabling us to multi-task between all the juice (or summarize the findings using some Artificial Intelligence and/or Fuzzy logic). Enough!!!!

In addition, there are surely many other things we could do to spice up and make this great initiative more crispy and delicious.

Actually (I am no programmer, so please ignore the rest of this post if it does not make sense), the technology behind this tool is not spectacular, but the idea is creative and innovative (Respect!). As far as I understand (after watching the Channel News video. Yeah, I liked the Chicken Little promotion method, too!), it all came about when one whizz kid (founder) simply got fed up going to all these sites to do his online researching and solved his problem by creating Schoolr (all-in-one), and by doing so he has actually made our research life easier (if we use it, too).

So, if you are fed up, got a problem, or frustrated with something?

Please, remember that problems and frustrations are great opportunities to discover, invent, create, innovate,change the world, become famous, and make big bucks :)

Read more »

Friday, February 13, 2015

Send One Dashboard selects input controls to another Dashboard selects values comes from first dashboard selects and sit in Dashboard 2 selects in Pentaho CDE

Hi Guys,

This post will talk about below scenario........

Scenario Explained:
When you navigate from one dashboard to another dashboard , in some cases you might need to pass the selected parameter values on Dashboard 1  to  Dashboard 2 selects.

i.e., In simple terms, it is not the category names passing from any chart on performing click action but it is passing the input controls values from one dashboard selects to another dashboard selects. (Take input controls from DB-1 and make them to sit on input controls of DB-2 and then allow user to select other inputs if he/she wants on it)

This sample is developed on : C-Tools of 14.06.18.1 stable version of CDE,CDF,CDA with bootstrap supported.

You can perform below :
1) Default values for selects (dates and other drop downs)
2) Select user wished inputs in selects on Dashboard-1.
3) Provide a button/link to drill down to Dashboard-2 with the selected inputs on Dashboard-1.
4) On Dashboard-2 selects , the values will coming from Dashboard-1 will be placing.
5) Components(Charts and tables and etc) on Dashboard-2 will listen to these input selects.
6) Change the inputs to other values by selecting here on Dashboard-2 and corresponding components will listen to them again.
7) Link/Button to drill back to Home dashboard -It can be default stage of Dashboard-1 OR reversely can apply the same logic to place the changed values of DB-2 up on DB-1 selects.

In this example I have taken 3 inputs on Dashboard-1.
They are :
1) From Date
2) To Date and
3) ID

Dashboard -1 Development : 
Step-1 : Lay Out

Below code is for : A panel with body and to for the place holder for lables and selects(Dates and others) and majorly for a Button(On which we are going to do some magic). 

Row ->Column -> HTML
and the Bootstrap HTML code is :

<div class="col-md-12 ">
    
            <div class="panel panel-primary">
            
            <div class="panel-heading">
                
                <h3 class="panel-title" id="DashboardName">Dashboard-1 Send the Selected Parameters to Dashbaord-2 Selects
                
               
                 <button onclick="sendParameters()" type="button" class="btn btn-default btn-xs pull-right">
                   Dashboard-2
                </button>
                </h3>
                <div class="clearfix"></div>  
                    
                
            </div>
            
            <div class="panel-body">
              <span class="labelcss"><b>From Date</b></span>
              <span id="FromDateSelect"></span>
              &nbsp;&nbsp;
              <span class="labelcss2"><b>To Date</b></span>
              <span id="ToDateSelect"></span>
              
              &nbsp;&nbsp;
              <span class="labelcss3"><b>ID</b></b></span>
              <span id="IDSelect"></span>
              
            </div>
            
            </div>
</div> 

Step 2: Creating parameters and Selects 
As shown in below figure create 3 parameters and selects for them.
i.e., param1_FromDate, param2_ToDate,param3_ID for parameters
and select1_FromDate, select2_ToDate and select3_ID for selects 

Make the selects to listen to the associated parameters.
Note that in this example I have not taken any SQL for drop down selects instead created an array for drop down.


Step : 3
Have a preview of the dashboard once done with step 2 and you can observe there you will not be drill down action when clicking on button component.

Here, lets come back to Lay out section and add a Java Script resource.
Write below code in Java Script Code Snippet

function sendParameters(){
    
   //Test whether your parameters holding the values in an alert message 
    alert("From Date="+param1_FromDate+"
"+"To Date="+param2_ToDate+"
"+"ID="+param3_ID);

   
//Perform drill down to 2nd dashboard when clicking on Button Component 
var url=
http://localhost:8080/pentaho/api/repos/%3Apublic%3AExplore%3ACDEExploring%3ADevelopement%3AParametersPassingFromDB1SelectsToDB2Selects%3ADashboard2.wcdf/generatedContent;
       
 //Open up 2nd dashboard with parameters passing along with URL   
window.location=
url+?send1_FromDate=+param1_FromDate+&send2_ToDate=+param2_ToDate+&send3_ID=+param3_ID;
       

}

Dashboard -2 Development :

Development of this dashboard has to done separately to take its URL on Dashboard -1 java script

Develop your dashboard with the same input controls (Why to develop again ? Let us SAVE AS with other name and with few modifications - Remove script code, make button component URL in HTML script for HOME dashboard)

Add below script in Java Script Code snippet resource..
i.e., Capturing the values into parameters and internally the selects will take these input values..and later on Dashboard-2 user can select/change on input values on different selection.

param1_FromDate= Dashboards.getQueryParameter(send1_FromDate);
param2_ToDate= Dashboards.getQueryParameter(send2_ToDate);
param3_ID= Dashboards.getQueryParameter(send3_ID);

Dashboards.getQueryParameter(<parameterSenderStringFromDashboad1>) will capture the value from the URL and assign these values to respective parameters.

Thats all, you are done....

Sample output Images : 
CASE-1: 
i). With Default Values On Dashboard-1
ii).Perform Click Action on Dashboard-2 Button and Test the select values in an Alert Message
iii) Observe the values for select components on Dashboard-2 after clicking OK button. 



CASE-II Images : 
i) With User Selected Values On Dashboard-1
ii) Test with alert Message after performing click action on Dashboard-2 button

iii) Observe the values for select components on Dashboard-2 after clicking OK button. 
iv) Make Other selections on Dashboard-2

Download the above qualified Example :  Click Me

Download a quick simple example here :  Click Me

Readers and community developers are encouraged to add your feedback ,suggestions and/or improvement of this post in comments section.

Sadakar Pochampalli
BI developer
(Jasper/Pentaho/Talend ETL)
Hyderabad, Telangana. 
Read more »