4. Cloud computing ?
• everything as a service
(and more) PAAS !
SAAS ! IAAS !
Cloud !
Cloud SA SaaS AG
• consider IT as a facility Cloud
computing
expert summit
provided on demand
June 30th, 2010 Yves Leblond @small_talks
5. The great IAAS leap forward ;-)
Before IAAS After IAAS
add some RAM, CPU, servers
and see what happens...
I have the solution : provision
but had to wait for budget,
some virtual machines ;-)
purchase and delivery... so
think twice
Does anyone knows what this What is this virtual machine
server is there for ? don’t for ? anyway, it costs ‘only’
unplug it ! 100!/month. don’t touch !.
(even in big banks...)
June 30th, 2010 Yves Leblond @small_talks
6. The owner point of
view
more flexible
Cheaper
June 30th, 2010 Yves Leblond @small_talks
7. What may happen if wild
usages (as usual?)
the more systems we
Virtualisation have, the more we are happy !
is our new game ! The worst the software is, the most
Give us more System we have work
fun ! administrators That will never change !
June 30th, 2010 Yves Leblond @small_talks
8. “Good practices usage” is the key to cloud
computing implementation projects
• ITSM ‘in the IAAS cloud’ :
new constraints, but stay rigorous (even more)
• Software design ‘in the PAAS cloud’:
think scalability and cloud deployment
• Learn, then use best practices, cloud application
frameworks, etc...
• Or...
June 30th, 2010 Yves Leblond @small_talks
9. Lets take the developer
(and user) point of view
IAAS (may be) part of the solution.
but not the solution
SOFTWARE DESIGN
USER SOLUTION DESIGN
June 30th, 2010 Yves Leblond @small_talks
21. Apex language
trigger blockDuplicates_tgr on Lead bulk(before insert, before update) {
/*
* begin by building a map which stores the (unique) list of leads
* being inserted/updated, using email address as the key.
*/
Map<String, Lead> leadMap = new Map<String, Lead>();
for (Lead lead : System.Trigger.new) {"
if (lead.Email != null) { // skip null emails
" /* for inserts OR
" * updates where the email address is changing
" * check to see if the email is a duplicate of another in
" * this batch, if unique, add this lead to the leadMap
" */
" if ( System.Trigger.isInsert ||
" " (System.Trigger.isUpdate &&
"lead.Email != System.Trigger.oldMap.get(lead.Id).Email)) {
""
" if (leadMap.containsKey(lead.Email)) {
" lead.Email.addError('Another new lead has the same email address.');
" } else {
" leadMap.put(lead.Email, lead);
" }
" }
}
}
/* Using the lead map, make a single database query,
* find all the leads in the database that have the same email address as
* any of the leads being inserted/updated.
*/ June 30th, 2010 Yves Leblond @small_talks
for (Lead lead : [select Email from Lead where Email IN :leadMap.KeySet()]) {
22. Apex usage
• triggers
• classes (internal or web services)
• batch processing
• Visualforce controllers
• ...
June 30th, 2010 Yves Leblond @small_talks
23. SOQL - SOSL
• SOQL (Salesforce Object Query Language)
• “select” : more or less the SQL logic for querying
objects stored in DB
• “insert, update, delete” : used for loaded/instantiated
objects (one or many per request), not like SQL
processing logic (more like a “persistence layer”).
• SOSL (Salesforce Object Search Languages)
• text based search (full text indexes)
June 30th, 2010 Yves Leblond @small_talks
25. Security and
user management
• by roles (company organigram)
• by profile (manager, vendor, project mgr)
• can be refined using complexe rules (e.g.
depending of attributes values)
• immediate and automatic propagation
June 30th, 2010 Yves Leblond @small_talks
27. Packaging
• a set of custom object definitions, classes,
trigger definitions,VisualForce components
• “packaged” together
• to be moved from on org to another
• Versioning and dependancies
• Installation and uninstallation (removing associated data)
• Unit tests mandatory !
• 75% of code must be covered by unit tests before
being packaged...
June 30th, 2010 Yves Leblond @small_talks
28. Sandbox
• a complete copy of your company data (called your
“organisation”), where you can :
• deploy new packages version
• deploy other company applications
• and test them for real
Have you ever dream of such a test environment ???
think to the efforts, human and financial ressources,
to have a test environment always up to date...
June 30th, 2010 Yves Leblond @small_talks
29. force.com governor
Governor limit : execution time, external calls per
transaction, SOQL statements per transaction, ...
Limit Trigger Anonymous Block, ...
Total number of SOQL queries issued2 20 100
Total number of records retrieved by SOQL queries 1000 10000
Total number of SOSL queries issued 0 20
Total number of records retrieved by a single SOSL query 0 200
Total number of DML statements issued (insert, update, upsert, merge, delete,
or database.emptyRecycleBin) 20 100
Total number of records processed as a result of DML statements or
database.emptyRecycleBin 100 10000
....
June 30th, 2010 Yves Leblond @small_talks
30. force.com governor
The governor is there to guarantee
performance and scalability fo all
customers.
June 30th, 2010 Yves Leblond @small_talks
31. Best practices
Governor (performance constraints), mandatory unit
tests, bulk management processing and most of the
salesforce constraints
help also developer to apply best software practices
even if it is sometimes frustrating ;-), if used to “Code and Go Live”.
June 30th, 2010 Yves Leblond @small_talks
32. 3. At the heart :
the multitenant
architecture
June 30th, 2010 Yves Leblond @small_talks
33. “There is only one salesforce
database worldwide shared by all
salesforces organisations and
customers”
And it is a giant Oracle Database, located in US,
Singapore, and next in Europe data centers.
June 30th, 2010 Yves Leblond @small_talks
39. This is where important
part of SF “know how” is
(patented) : how to
guarantee request
response time....
Salesforce rebuild a query engine for the databases
in order to manage
300.000.000 transactions every day,
very little servers
and an average response time of 270ms
see http://trust.salesforce.com for live stats
June 30th, 2010 Yves Leblond @small_talks
40. and Java ?
• Internally, there is a lot of java :
• APEX is precompiled in java code
• it seems that VisualForce generates Java
Faces code
• ...
• But you don’t see it ;-)
June 30th, 2010 Yves Leblond @small_talks
42. One of the integration options
• Flex • Amazon • Python
• .net & VB • AJAX • Cocoa
• Ruby • java
• Google • PHP • Any WSDL consumer
(APEX classes can be
• Perl • Facebook declared as web
services)
June 30th, 2010 Yves Leblond @small_talks
44. try {
binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
} catch (ServiceException ex1) {
System.out.println(ex1.getMessage());
return;
}
try {
lr = binding.login(userName, pwd);
} catch (UnexpectedErrorFault ex2) {
connect
System.out.println(ex2.getExceptionMessage() + "nn"
return;
} catch (LoginFault ex2) {
System.out.println(ex2.getExceptionMessage() + "nn");
return;
} catch (RemoteException ex2) {
System.out.println(ex2.getMessage() + "nn");
return;
}
// create a variable to hold the query result
QueryResult qr = null;
// call the query saving the results in qr SOQL request
try {
qr = binding
.query("select Name, numberOfEmployees, Id, Industry from Account");
} catch (UnexpectedErrorFault uef) {
System.out.println(uef.getExceptionMessage() + "nn");
return;
} catch (Exception e) {
e.printStackTrace();
System.out.println("nn");
java
return;
}
if (qr != null) {
SObject[] records = qr.getRecords();
_accounts = new Account[records.length];
// we can loop through the returned records
for (int i = 0; i < records.length; i++) {
// Because we asked for accounts we will convert
// the SObject for each record into an Account object
Account account = (Account) records[i];
_accounts[i] = account;
// Now we can access any of the fields we had in the query
// select clause directly from the account variable
System.out.print(new Integer(i).toString() + ". ");
System.out.print(account.getName() + " - ");
System.out.println(account.getId());
}
June 30th, 2010 Yves Leblond @small_talks
45. Data management
using “Partner WSDL”
weakly typed, based on
generic metadata infos
June 30th, 2010 Yves Leblond @small_talks
46. private void querySample() {
...
QueryResult qr = null;
QueryOptions qo = new QueryOptions();
qo.setBatchSize(new Integer(3));
binding.setHeader(new SforceServiceLocator().getServiceName()
.getNamespaceURI(), "QueryOptions", qo);
SOQL request
try {
qr = binding.query("select FirstName, LastName from Contact");
int loopCount = 0;
boolean continueLoop = true;
while (continueLoop) {
java, but
// process the query results
for (int i = 0; i < qr.getRecords().length; i++) {
SObject con = qr.getRecords()[i];
laborious.
String fName = "";
String lName = "";
(like in old JDBC)
if (con.get_any()[0].getName().toLowerCase().equals(
"firstname")) {
fName = con.get_any()[0].getValue();
lName = con.get_any()[1].getValue();
} else
lName = con.get_any()[0].getValue();
if (fName == null) {
System.out.println("Contact " + (i + 1) + ": " + lName);
} else {
System.out.println("Contact " + (i + 1) + ": " + fName
+ " " + lName);
}
}
// handle the loop + 1 problem by checking to see if the most
// recent queryResult
if (qr.isDone())
continueLoop = false;
else
qr = binding.queryMore(qr.getQueryLocator());
}
System.out.println("nQuery succesfully executed.");
getUserInput("nHit return to continue...");
} catch (ApiFault af) {
System.out
.println("nFailed to execute query succesfully, error message was: n"
+ af.getExceptionMessage());
June 30th, 2010
getUserInput("nHit return to continue...");
} catch (Exception ex) {
Yves Leblond @small_talks
47. Even metadata
management can be
done in Java...
June 30th, 2010 Yves Leblond @small_talks
48. ex : creation of a new kind of
Custom Object type
private void createCustomObject()
{
"
"
CustomObject co = new CustomObject();
String name = "My Custom Object";
NB :
"
"
co.setFullName("MyCustomObject" + "__c");
co.setDeploymentStatus(DeploymentStatus.Deployed);
the Force.com IDE
"
"
co.setDescription("Created by the Metadata API Sample");
co.setEnableActivities(true); (eclipse plugin)
"
"
co.setLabel(name);
co.setPluralLabel(co.getLabel() + "s"); use this.
" co.setSharingModel(SharingModel.ReadWrite);
" CustomField nf = new CustomField();
" nf.setType(FieldType.Text);
" nf.setDescription("The custom object identifier on page layouts, " +
"related lists etc");
" nf.setLabel("My Custom Object");
" nf.setFullName("MyCustomObject" + " __c");
null)try { AsyncResult[] ars = metadatabinding.create(new CustomObject[] { co }); if (ars ==
" {
" " System.out.println("The object was not created successfully"); return;
" }
" String createdObjectId = ars[0].getId();"
" String[] ids = new String[] {createdObjectId};
" boolean done = false;
" long waitTimeMilliSecs = ONE_SECOND;
" AsyncResult[] arsStatus = null;
"
" ….
June 30th, 2010 Yves Leblond @small_talks
50. VMforce ?
• VMforce : Spring applications on top of this
• Custom Objects : your data
• Native GUI and customization
• Workflow, Rules, Security profiles, ...
• Apex Classes and Triggers : processing
• VisualForce : native MVC framework
June 30th, 2010 Yves Leblond @small_talks
52. • Spring :
• Spring Framework
• SpringSource TC server (Server® runtime, the Enterprise version of
Apache Tomcat)
• force.com
• force.com services
• force.com database
• everything we talked before : including automatic scalability, high
availability, auto-tuning, back up and disaster recovery....
• VMware
• vCloud technology: Automatic management of the Java stack that
powers VMforce applications
• VMware vSphere: Industry leading virtualization platform will provide
the resource isolation, management, and virtualization
June 30th, 2010 Yves Leblond @small_talks