cle_clock
Home > wikikonf >  was/actions/by kikonf > cache







Cache

print

Action : was.cache   (Category : was, Name : cache, By : kikonf)
Complete Name : was.cache.by.kikonf
Version : 5.0        License : Modified BSD License

Purpose of the was category :
Easy to customize. This category use in background the wsadmin command in jython mode (through AdminConfig, AdminControl and AdminTask), to drive WebSphere Application Server configuration.
You can use it to manage the whole WebSphere architecture.

Purpose of this cache plugin : Creates a new ObjectCacheInstance

The following shows the main Source Code File for the Action : was.cache

Toggle lines
##  Copyright (c) 2008, Patrick Germain Placidoux
##  All rights reserved.
##
##  This file is part of Kikonf Public Software.
##
##  Kikonf Public Software is released under the modified BSD License,
##  which should accompany it or any part of it in the file "COPYING".
##  If you do not have this file you can access the license 
##  through the WWW at http://www.kikonf.org/license/bsd/license.txt.
## 
##  Home: http://www.kikonf.org
##  Contact: kikonf@gmx.com




from actions.was.tools import *



class Cache(wasAction):

    def extract(self, scope_attrs=None, name=None, prefix=None, **keywords): 
        self_funct='extract'
        self.verbose(scope_attrs, name=name, prefix=prefix)
        scope_id, scope_attrs, scope=self.getScope(scope_attrs=scope_attrs, indent=self.getIndent())
        indent=self.getIndent() + 3*' '
        
        verbose('ObjectCacheInstance listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        cs=getStartByNameAsDict(split(AdminConfig.list('ObjectCacheInstance', scope_id)))
        verbose('ObjectCacheInstances listed.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
        
        for cname in cs.keys():
            
            if prefix!=None and name!=None and cname==prefix + '_' + name \
            or prefix==None and name!=None and cname==name \
            or prefix!=None and name==None and cname.startswith(prefix) \
            or prefix==None and name==None:
            
                verbose('Found matching ObjectCacheInstance:' + cname + '.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
                cache_node=self.newTop() #-- because in extract mode, each call returns a new blank top node.
                caches=getShowAsDict(AdminConfig.show(cs[cname]))                
                
                _name=cname
                if prefix!=None:_name=cname.split(prefix + '_')[1]
                
                desc=None
                if caches.has_key('description') and caches['description']!=None:desc=caches['description'][1:-1]
                if desc==DESIGN_NOTICE:desc=None
                
                cache_node.setAttrs(name=_name, jndi_name=caches['jndiName'], size=caches['cacheSize'], desc=desc, prefix=prefix)
                
                mkNodeScope(cache_node, scope_attrs, isUnique=True) #-- creates a scope node.

    def remove(self, no_name, no_name_no_prefix):
        cache_node = self.getTop()        
        cache_attrs = cache_node.getAttrs()
        scope_id, scope_attrs, scope=self.getScope(parent_node=cache_node, indent=self.getIndent()) #-- Retreives scope

        # no_name/no_name_no_prefix
        prefix=cache_attrs.prefix        
        name=cache_attrs.name
        if no_name or no_name_no_prefix:name=None
        if no_name_no_prefix:prefix=None    
        
        self.verbose(scope_attrs, name=name, prefix=prefix)
        indent=self.getIndent() + 3*' '
        
        self.rmvCache(name=name, prefix=prefix, indent=indent)
          
    def inject(self):
        self_funct='inject'
        cache_node = self.getTop()        
        cache_attrs = cache_node.getAttrs()        
        scope_id, scope_attrs, scope=self.getScope(parent_node=cache_node, indent=self.getIndent()) #-- Retreives scope

        self.verbose(scope_attrs, name=cache_attrs.name, prefix=cache_attrs.prefix)
        indent=self.getIndent() + 3*' '
        
        #-- remove first
        self.rmvCache(name=cache_attrs.name, prefix=cache_attrs.prefix, indent=indent)

        #-- name
        if cache_attrs.prefix==None:name=cache_attrs.name
        else:name=cache_attrs.prefix + '_' + cache_attrs.name
        # -- desc
        if cache_attrs.desc==None:desc=DESIGN_NOTICE
        else:desc=cache_attrs.desc

        cmdvalues=[]
        cmdvalues.append(['name', name])
        cmdvalues.append(['jndiName', cache_attrs.jndi_name])
        cmdvalues.append(['cacheSize', cache_attrs.size])
        cmdvalues.append(['defaultPriority', 1])
        cmdvalues.append(['enableDiskOffload', 'false'])
        cmdvalues.append(['flushToDiskOnStop', 'false'])
        cmdvalues.append(['useListenerContext', 'false'])
        cmdvalues.append(['disableDependencyId', 'false'])
        cmdvalues.append(['description', desc])
        
        # Creates
        verbose('ObjectCacheInstance retreiving.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        wpv=AdminConfig.getid(scope.getCP() +'/CacheProvider:/')
        
        AdminConfig.create('ObjectCacheInstance', wpv, cmdvalues)
        verbose('ObjectCacheInstance:' + name + ' created.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
        
    def rmvCache(self, name=None, prefix=None, indent=None):
        scope_id, scope_attrs, scope=self.getScope()
        
        verbose('ObjectCacheInstance listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        cs=getStartByNameAsDict(split(AdminConfig.list('ObjectCacheInstance', scope_id)))
        verbose('ObjectCacheInstances listed.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
        
        for cname in cs.keys(): 
            if cname=='':continue
            if prefix!=None and cname.startswith(prefix) \
            or prefix==None and name!=None and name==cname \
            or prefix==None and name==None:
                verbose('ObjectCacheInstance:' + cname + ' removing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
                AdminConfig.remove(cs[cname])
                verbose('ObjectCacheInstance:' + cname + ' removed.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())

    def verbose(self, scope_attrs, name=None, prefix=None):
        scope=str(scope_attrs).replace("'", '')[1:-1]
        
        if name!=None and prefix!=None:verbose('ObjectCacheInstance:' + name +', under prefix:' + prefix + ', at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent(), logFile=self.getLogFile())
        elif name!=None and prefix==None:verbose('ObjectCacheInstance:' + name + ', at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent(), logFile=self.getLogFile())
        elif prefix!=None:verbose('ObjectCacheInstances under prefix:' + prefix + ', at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent(), logFile=self.getLogFile())
        else:verbose('ObjectCacheInstances at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent(), logFile=self.getLogFile())
							
(Source: <KIKONF_INSTALLATION_DIR>/plugins/actions/was/cache/by/kikonf/cache.py)


  • Line 1 to 3 say something , say something , say something
  • Line 10 to 17 say something , say something , say something , say something , say something
  • Line 20 to 25 say something



Trademarks :
  • "IBM", "WebSphere", "WebSphere Aplication Server", "WAS" are registred trademarks of International Business Machines Corporation.
  • "Java" and "JVM" are a registred trademarks of Oracle and/or its affiliates.
  • Other names may be trademarks of their respective owners.

Copyright © 2011 - Patrick Placidoux, Hélène Malamoud