Showing posts with label amberpoint. Show all posts
Showing posts with label amberpoint. Show all posts

Friday, July 19, 2013

OSB service discovery code (poor man's Amberpoint)

This will generate SQL code to display dependencies. You need to create 3 tables: ACME2_OSBPROJECTS, ACME2_SERVICES, ACME2_SERVICE_DEPENDENCIES

  CREATE TABLE "ACME2_OSBPROJECTS" 
   ( "OSBPROJECTNAME" VARCHAR2(50 BYTE), 
 "MESSAGESPERDAYMAX" NUMBER(10,0), 
 "PROJECTNAME" VARCHAR2(50 BYTE), 
 "DEPLOYMENT_ORDER" NUMBER DEFAULT 1, 
 "MESSAGESPERDAYMIN" NUMBER(10,0)
   ) ;

   

  CREATE TABLE "ACME2_PROJECTS" 
   ( "PROJECTNAME" VARCHAR2(20 BYTE), 
 "DOMAINNUMBER" VARCHAR2(20 BYTE), 
 "TYPE" VARCHAR2(20 BYTE), 
 "BUSINESSAREA" VARCHAR2(20 BYTE), 
 "REMARKS" VARCHAR2(100 BYTE), 
 "STATUS" VARCHAR2(20 BYTE) DEFAULT 'ACTIVE'
   ) ;


  CREATE TABLE "ACME2_SERVICE_DEPENDENCIES" 
   ( "SERVICE" VARCHAR2(200 BYTE), 
 "DEPENDENTSERVICE" VARCHAR2(200 BYTE)
   ) ;


  CREATE UNIQUE INDEX "ACME2_OSBPROJECTS_PK" ON "ACME2_OSBPROJECTS" ("OSBPROJECTNAME")   ;

  CREATE UNIQUE INDEX "ACME2_PROJECTS_PK" ON "ACME2_PROJECTS" ("PROJECTNAME")   ;

  CREATE UNIQUE INDEX "ACME2_SERVICE_DEPENDENCI_UK1" ON "ACME2_SERVICE_DEPENDENCIES" ("SERVICE", "DEPENDENTSERVICE")   ;

  ALTER TABLE "ACME2_OSBPROJECTS" MODIFY ("DEPLOYMENT_ORDER" NOT NULL ENABLE);
  ALTER TABLE "ACME2_OSBPROJECTS" ADD CONSTRAINT "ACME2_OSBPROJECTS_PK" PRIMARY KEY ("OSBPROJECTNAME") ENABLE;
  ALTER TABLE "ACME2_OSBPROJECTS" MODIFY ("OSBPROJECTNAME" NOT NULL ENABLE);

  ALTER TABLE "ACME2_PROJECTS" ADD CONSTRAINT "ACME2_PROJECTS_CHK3" CHECK (DOMAINNUMBER IN ('1', '2', '3', '4', 'ALL', 'NONE')) ENABLE;
  ALTER TABLE "ACME2_PROJECTS" ADD CONSTRAINT "ACME2_PROJECTS_CHK4" CHECK (STATUS IN ('ACTIVE', 'DEAD', 'FUTURE')) ENABLE;
  ALTER TABLE "ACME2_PROJECTS" MODIFY ("STATUS" NOT NULL ENABLE);
  ALTER TABLE "ACME2_PROJECTS" MODIFY ("DOMAINNUMBER" NOT NULL ENABLE);
  ALTER TABLE "ACME2_PROJECTS" ADD CONSTRAINT "ACME2_PROJECTS_CHK2" CHECK (BUSINESSAREA IN ('Frontend', 'Backend')) ENABLE;
  ALTER TABLE "ACME2_PROJECTS" ADD CONSTRAINT "ACME2_PROJECTS_CHK1" CHECK (TYPE IN ('NonCritical', 'Critical')) ENABLE;
  ALTER TABLE "ACME2_PROJECTS" ADD CONSTRAINT "ACME2_PROJECTS_PK" PRIMARY KEY ("PROJECTNAME") ENABLE;
  ALTER TABLE "ACME2_PROJECTS" MODIFY ("PROJECTNAME" NOT NULL ENABLE);

  ALTER TABLE "ACME2_SERVICE_DEPENDENCIES" ADD CONSTRAINT "ACME2_SERVICE_DEPENDENCI_UK1" UNIQUE ("SERVICE", "DEPENDENTSERVICE") ENABLE;
  ALTER TABLE "ACME2_SERVICE_DEPENDENCIES" MODIFY ("DEPENDENTSERVICE" NOT NULL ENABLE);
  ALTER TABLE "ACME2_SERVICE_DEPENDENCIES" MODIFY ("SERVICE" NOT NULL ENABLE);

  ALTER TABLE "ACME2_OSBPROJECTS" ADD CONSTRAINT "ACME2_OSBPROJECTS_ACME2_FK1" FOREIGN KEY ("PROJECTNAME")
   REFERENCES "ACME2_PROJECTS" ("PROJECTNAME") ENABLE;




this is the code:


#There is a change to do to be able to run this WLST script:
#vi /opt/oracle/fmw11_1_1_5/osb/common/bin/wlst.sh
#change this:
#export CLASSPATH
#into this:
#CLASSPATH=/opt/oracle/fmw11_1_1_5/osb/lib/sb-kernel-api.jar:/opt/oracle/fmw11_1_1_5/osb/modules/com.bea.common.configfwk_1.5.0.0.jar:$CLASSPATH
#export CLASSPATH


import javax.management
import java.util
import javax.management.remote
import javax.naming
import weblogic.management.mbeanservers.domainruntime
import com.bea.wli.sb.management.configuration

from java.util import Hashtable
from java.util import HashSet
from javax.management.remote import JMXServiceURL
from weblogic.management.mbeanservers.domainruntime import DomainRuntimeServiceMBean
from javax.naming import Context
from javax.management.remote import JMXConnectorFactory
from javax.management import ObjectName
from com.bea.wli.sb.management.configuration import SessionManagementMBean
from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean
from com.bea.wli.config import Ref

from com.bea.wli.config.env import EnvValueQuery
from com.bea.wli.config.env import QualifiedEnvValue
from com.bea.wli.config.resource import DependencyQuery
from com.bea.wli.sb.management.query import ProxyServiceQuery
from com.bea.wli.sb.management.query import BusinessServiceQuery

from com.bea.wli.sb.util import EnvValueTypes
from java.util import Collection
from java.util import Collections



def displayAllProjectsAndServices():
    sb = ""
    refs = configMBean.getRefs(Ref.DOMAIN)
    refsList = ArrayList()
    refsList.addAll(refs)
    
    for ref in refs:
        if (ref.isProjectRef()) :
            sb = sb + ("insert into ACME2_OSBPROJECTS (OSBPROJECTNAME) values ('" + ref.getFullName() + "');\n")
        
    sb = sb + "\n\n\n"
    
    for ref in refsList :
        if ref.getTypeId() == "ProxyService" or ref.getTypeId() == "BusinessService" :
            if ref.getTypeId() == "ProxyService" :
                isPS = "1"
            else:
                isPS =  "0"
            sb = sb + ("INSERT INTO ACME2_SERVICES (SERVICENAME, SERVICEFULLPATH, OSBPROJECTNAME, ISPS) values ('" + ref.getLocalName() + "', '" + ref.getFullName() + "', '" + ref.getProjectName() + "', '" + isPS + "');\n")
            sb = sb + ("UPDATE ACME2_SERVICES set SERVICENAME = '" + ref.getLocalName() + "', OSBPROJECTNAME='" + ref.getProjectName() + "', ISPS = '" + isPS + "' where SERVICEFULLPATH = '" + ref.getFullName() + "';\n")
    
    
    sb = sb + "\n\n\n"
    return sb


def getAllServiceURIs():
    sb = ""
    evquery = EnvValueQuery(None, Collections.singleton(EnvValueTypes.SERVICE_URI), None, False, None, False)
    founds = configMBean.findEnvValues(evquery)
    for value in founds: 
        sb = sb + ("UPDATE ACME2_SERVICES set SERVICE_URI = '" + value.getValue() + "' where SERVICEFULLPATH ='" + value.getOwner().getFullName() + "';\n")
    return sb
    
    
def getAllProxyServices():    
    sb = ""
    query = ProxyServiceQuery()
    refs = configMBean.getRefs(query)
    for ref in refs:
        uriObject = configMBean.getEnvValue(ref, EnvValueTypes.SERVICE_URI, None)
        if uriObject == None:
            uri = "NULL"
        else:
            uri = uriObject
        sb = sb + ("UPDATE ACME2_SERVICES set SERVICE_URI ='" + uri + "', TYPE = '" + lookupType(uri) + "', ISPS = 1 where SERVICEFULLPATH = '" + ref.getFullName() + "';\n")
    
    return sb

def getAllBusinessServices():    
    sb = ""
    query = BusinessServiceQuery()
    refs = configMBean.getRefs(query)
    for ref in refs:
        uri = getBusinessServiceURI(ref)
        sb = sb + ("UPDATE ACME2_SERVICES set SERVICE_URI ='" + uri + "', TYPE = '" + lookupType(uri) + "', ISPS = 0 where SERVICEFULLPATH = '" + ref.getFullName() + "';\n")
    return sb
    



def getDependentServices():
    sb = ""
    psQuery = ProxyServiceQuery()
    myPSSet = configMBean.getRefs(psQuery)
    for myPS in myPSSet:
        depQuery = DependencyQuery(Collections.singleton(myPS), False)
        refs = configMBean.getRefs(depQuery)
        for ref in refs:
            if (ref.getTypeId() == "BusinessService" or ref.getTypeId() == "ProxyService"):
                sb = sb + ("INSERT INTO ACME2_SERVICE_DEPENDENCIES (SERVICE, DEPENDENTSERVICE) values ('" + myPS.getFullName() + "', '" + ref.getFullName() + "');\n")
    return sb
    

def getBusinessServiceURI(ref):
    envValueTypesToSearch = HashSet()
    envValueTypesToSearch.add(EnvValueTypes.SERVICE_URI);
    evquery = EnvValueQuery(None, envValueTypesToSearch, Collections.singleton(ref), False, None, False )
    founds = configMBean.findEnvValues(evquery);
    uri = ""
    for qev in founds:
        if (qev.getEnvValueType() == EnvValueTypes.SERVICE_URI):
            uri = qev.getValue()
    return uri;
    


def lookupType(uri):
    result = "NONE"
    if (uri == None) :
        result = "LOCAL"
    elif uri.startswith("/") :
        result = "HTTP"
    elif (uri.startswith("jca://eis/DB/")):
        result = "DBADAPTER"
    elif (uri.startswith("flow:")):
        result = "SPLITJOIN"
    elif (uri.startswith("http://")):
        result = "HTTPBS"
    elif (uri.startswith("jca://eis/FileAdapter")):
        result = "HAFILEADAPTER"
    elif (uri.startswith("jca://eis/Ftp/")):
        result = "FTPADAPTER"
    elif (uri.startswith("jms:")):
        result = "JMS"
    return result;



sessionName = "MySession"
hostname='ACME.reacm.com'
port=7001
username='Pierluigi'
password='weblogic1'
serviceURL=JMXServiceURL("t3", hostname, port, "/jndi/" + DomainRuntimeServiceMBean.MBEANSERVER_JNDI_NAME)
h=Hashtable()
h.put(Context.SECURITY_PRINCIPAL, username)
h.put(Context.SECURITY_CREDENTIALS, password)
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote")

conn = JMXConnectorFactory.connect(serviceURL, h)

mbconn = conn.getMBeanServerConnection()

sm = JMX.newMBeanProxy(mbconn, ObjectName.getInstance(SessionManagementMBean.OBJECT_NAME), SessionManagementMBean)

sm.createSession(sessionName)

configMBean = JMX.newMBeanProxy(mbconn, ObjectName.getInstance("com.bea:Name=" + ALSBConfigurationMBean.NAME + "." + sessionName + ",Type=" + ALSBConfigurationMBean.TYPE), ALSBConfigurationMBean)

print displayAllProjectsAndServices()
print getAllProxyServices()
print getAllBusinessServices()
print getAllServiceURIs()
print getDependentServices()


sm.discardSession(sessionName)
conn.close()




Monday, May 24, 2010

AmberPoint for Dummies

So, you are lined up for a telephone inteview where you must pretend to have working experience with AmberPoint. Here is some BS you might reuse. If you get hired, send me a penny.

Amberpoint Management System (AMS) can be configured using these components:

plug-in agents
proxy agents
nano-agents (for EJBs, JDBC and RMI services, made by observer + monitor)
client side agents (to act as Security and Performance Monitoring proxy on the client side)

It offers:

- Container Discovery of Services (at startup)
- Publication of Services to a UDDI registry



- Dynamic Discovery of Service interdependency- at operation level
- Monitoring of Service/Operation performance
- Monitoring of Service/Operation faults
- Establish Correlations (=interrelated service operation calls)
- Monitor Correlations performance and faults
- Create "Conditions" (=observable pattern on a Service invokation) based on faults or on specific error response codes
- Report a configurable timeout on a Correlation

- Identify Service consumers (Customers) and provide statistics of Service Utilization per Customer
- Monitor SLA (performance, availability)

- Message Routing
- Message Logging on a per-service level
-


Using Environment Monitor (EM) enables:
- Automatic Fault Resolution, by constructing an action list

Saturday, May 22, 2010

Amberpoint Amberpoint on the wall, who in the land is fairest of all?

I am reading the Introduction to Amberpoint Management System, I felt this absolutely touching, story of my life:

Monitoring this process that crosses application, container, and network boundaries
poses many challenges. Are users experiencing significant delays? Are faults being
generated? If transactions are failing, at what point are they failing? What is the dollar
cost per fault being generated? Typically, these questions can only be answered by
trolling through reams of log files gathered from distributed machines, potentially
owned by different development teams. Worse, this work is usually forensic in nature.
The transaction has already failed and there is little that can be done until all of the
logs are collected and the various teams have sorted through the problems. Any
corrections must go through the development and deployment process, further
magnifying the expense of time and money.


To address these challenges, the complete transaction should be visible in real time:
each cooperating piece of infrastructure and service should be able to obtain the
policies that indicate how requests should be treated and how to report information
about performance, errors, and conditions of interest to the business owner. One
possibility would be to have all SOA components (services, containers, logging
infrastructure, security infrastructure) provide standard management handles that
enable them to transmit performance and dependency information and to enforce
policies that align performance with business goals. Unfortunately, these standards do
not yet exist
. Even if they did exist, it is unlikely they could be sufficiently broad to
accommodate the heterogeneity of SOA or to anticipate component types yet to be
invented. An alternative solution would be to support management functions by
instrumenting the environment in which SOA applications run. By adding a
configurable management layer, it would be possible to retain all the advantages of
SOA design without incurring additional costs at production time.