Lesson 1.2: Understand the OSGi configuration files
The OSGi sample includes configuration files that you use to start and configure the WebSphere® eXtreme Scale grid and server.
About this task
OSGi configuration files
- collocated.server.properties
- protoBufObjectGrid.xml
- protoBufDeployment.xml
- blueprint.xml
collocated.server.properties
A server configuration is required to start a server. When the eXtreme Scale server bundle is started, it does not start a server. It waits for the configuration PID,com.ibm.websphere.xs.server
, to be created with a server property file. This server
property file specifies the server name, port number, and other server properties.In most cases,
you create a configuration to set the server property file. In rare cases, you might want only to
start a server, with every property set to a default value. In that case, you can create a
configuration called com.ibm.websphere.xs.server
with value set to
default.
For more details about the server property file, see the Server properties file topic.
serverName=collocatedServer
isCatalog=true
catalogClusterEndPoints=collocatedServer:localhost:6601:6602
traceSpec=ObjectGridOSGi=all=enabled
traceFile=logs/trace.log
listenerPort=2809
JMXServicePort=1099
protoBufObjectGrid.xml
The sample protoBufObjectGrid.xml ObjectGrid descriptor XML file contains the following content, with comments removed.<objectGridConfig
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ibm.com/ws/objectgrid/config ../objectGrid.xsd"
xmlns="http://ibm.com/ws/objectgrid/config">
<objectGrids>
<objectGrid name="Grid" txTimeout="15">
<bean id="ObjectGridEventListener"
osgiService="myShardListener"/>
<backingMap name="Map" readOnly="false"
lockStrategy="PESSIMISTIC" lockTimeout="5"
copyMode="COPY_TO_BYTES"
pluginCollectionRef="serializer"/>
</objectGrid>
</objectGrids>
<backingMapPluginCollections>
<backingMapPluginCollection id="serializer">
<bean id="MapSerializerPlugin"
osgiService="myProtoBufSerializer"/>"/>
</backingMapPluginCollection>
</backingMapPluginCollections>
</objectGridConfig>
- ObjectGridEventListener
- The shard-level plug-in. For each ObjectGrid instance, there is an instance of ObjectGridEventListener. It is configured to use the OSGi service myShardListener. That means when the grid is created, the ObjectGridEventListener plug-in uses the OSGi service myShardListener with the highest service ranking available.
- MapSerializerPlugin
- The map-level plug-in. For the backing map named
Map
, there is a MapSerializerPlugin plug-in configured. It is configured to use the OSGI service myProtoBufSerializer. That means when the map is created, the MapSerializerPlugin plug-in uses the service, myProtoBufSerializer, with the highest ranked service ranking available.
protoBufDeployment.xml
The deployment descriptor XML file describes the deployment policy for the grid namedGrid
, which uses five partitions. See the
following code example of the XML file:<deploymentPolicy
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ibm.com/ws/objectgrid/deploymentPolicy ../deploymentPolicy.xsd"
xmlns="http://ibm.com/ws/objectgrid/deploymentPolicy">
<objectgridDeployment objectgridName="Grid">
<mapSet name="MapSet" numberOfPartitions="5">
<map ref="Map"/>
</mapSet>
</objectgridDeployment>
</deploymentPolicy>
blueprint.xml
As an alternative to using the collocated.server.properties file in conjunction with configuration PID,com.ibm.websphere.xs.server
, you can include the ObjectGrid XML and deployment XML
files in an OSGi bundle, along with a Blueprint XML file as shown in the following
example:<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:objectgrid="http://www.ibm.com/schema/objectgrid"
default-activation="lazy">
<objectgrid:server id="server" isCatalog="true"
name="server"
tracespec="ObjectGridOSGi=all=enabled"
tracefile="C:/Temp/logs/trace.log"
workingDirectory="C:/Temp/working"
jmxport="1099">
<objectgrid:catalog host="localhost" port="2809"/>
</objectgrid:server>
<objectgrid:container id="container"
objectgridxml="/META-INF/objectgrid.xml"
deploymentxml="/META-INF/deployment.xml"
server="server"/>
</blueprint>
Lesson checkpoint
In this lesson, you learned about the configuration files that are used in the OSGi sample. Now, when you start and configure the eXtreme Scale grid and server, you will understand which files are being used in these processes and how these files interact with your plug-ins in the OSGi framework.