OpenSolaris
Collectives
Discussions
Documentation
Download
Source Browser
Free CD
Log-in
|
en
Project vpanels
:
The Java SCF interfaces
Top Menu
Show
:
Comments
Attachments
History
Information
Print
:
Print
Print preview
Export as PDF
Export as RTF
Export as HTML
Export as XAR
Wiki code for
The Java SCF interfaces
Hide Line numbers
1: == Java SCF Interfaces == 2: 3: Perhaps the most stable component of the Visual Panels demo release are 4: the Java SCF interfaces. By "stable" we don’t mean to imply that you 5: can count on these interfaces staying the same ~-- they may change 6: significantly (probably based on your feedback or with your help) ~-- 7: but they aren’t something we expect to throw out and replace. At the 8: moment there is still considerable work to be done (e.g. error handling 9: is particularly egregious), but the interfaces should be fully 10: functional: there shouldn’t be anything you can do using the 11: [[{{code}}libscf(3lib){{/code}}>>http://docs.sun.com/app/docs/doc/816-5173/6mbb8adv7?a=view]] 12: interfaces that you can’t do with the Java interfaces. 13: 14: There is a subtle distinction between SCF, the service configuration 15: facility, and SMF, the service management facility. The former 16: represents the underlying mechanism of managing services, instances, 17: properties, etc. and the latter represent the policies we have 18: implemented on top of that mechanism. To cite an example, SCF gives us 19: property groups, SMF defines what a dependency group looks like. 20: 21: To reflect this division of responsibilities, we have two packages, 22: {{code}}org.opensolaris.os.scf{{/code}} for SCF and {{code}}org.opensolaris.os.smf{{/code}} for SMF. 23: Both packages can be accessed by including 24: {{code}}/opt/OSOL0vpanels/lib/java/scf.jar{{/code}} in your class path, and their 25: javadoc (albeit sorrowfully incomplete) can be found in 26: {{code}}/opt/OSOL0vpanels/lib/java/javdoc/scf{{/code}}. 27: 28: === {{code}}org.opensolaris.os.scf{{/code}} 29: 30: {{code}}org.opensolaris.os.scf{{/code}} ({{code}}o.o.o.scf{{/code}} for short) contains all the 31: functionality needed to interact with SCF. Though it talks to a native 32: library behind the scenes, it publishes interfaces which should feel 33: comfortable to a Java programmer. You can see where things line up, 34: though: the basic object model presented by the C library is 35: preserved. 36: 37: ==== Implementation 38: 39: {{code}}o.o.o.scf{{/code}} has both Java and native components. The Java component 40: lives in {{code}}usr/src/java/org/opensolaris/os/scf{{/code}}, and the native 41: component in {{code}}usr/src/lib/libscf_jni{{/code}}. 42: 43: ==== Use 44: 45: As when using {{code}}libscf(3lib){{/code}}, all access to the SMF repository starts 46: with a handle. In this case, a {{code}}o.o.o.scf.Handle{{/code}}. Unlike when using 47: the C library, you don’t need to create objects that routines can "fill 48: in". If you want to get the local scope (which you almost always do) 49: given a handle {{code}}h{{/code}}, you simply take the result of 50: {{code}}h.scope(Scope.SCF~_SCOPE~_LOCAL()){{/code}}. If you’re interested in the 51: instances of a service {{code}}svc{{/code}}, {{code}}svc.instances(){{/code}} will return an iterator 52: of type {{code}}Iterator<o.o.o.scf.Instance>{{/code}}. And so on. 53: 54: Errors are thrown as exceptions. Unfortunately, at the moment we 55: simply pass on the errno values from the failing {{code}}libscf{{/code}} calls. If 56: you plan on playing around with these interfaces, you’ll need to use a 57: 58: combination of the {{code}}libscf{{/code}} man pages, the javadoc, and possibly the 59: source until we’ve made the necessary improvements to both the error 60: handling and the documentation. 61: 62: === {{code}}org.opensolaris.os.smf{{/code}} 63: 64: {{code}}o.o.o.smf{{/code}} will contain all the SMF-specific knowledge, and is 65: implemented entirely on {{code}}o.o.o.scf{{/code}}. That is, it contains no non-Java 66: components. Currently, its scope is very limited; most of our effort 67: has necessarily been put into getting the underlying support working. 68: Despite it’s limited functionality, you’ll find several handy classes 69: in this package. 70: 71: ==== Implementation 72: 73: {{code}}o.o.o.smf{{/code}} is found entirely in 74: {{code}}usr/src/java/org/opensolaris/os/smf{{/code}}. 75: 76: ==== Use 77: 78: The {{code}}o.o.o.smf{{/code}} class can’t be used entirely on their own; they require 79: input in the form of {{code}}o.o.o.scf{{/code}} objects. The standard paradigm is for 80: there to be {{code}}o.o.o.smf{{/code}} objects which correspond to {{code}}o.o.o.scf{{/code}} objects 81: having the same name (currently prepended with "Smf", though that may 82: change) which take the latter as the argument to their constructors. 83: As with {{code}}o.o.o.scf{{/code}}, many of these classes have methods which return 84: collections f other {{code}}o.o.o.smf{{/code}} classes in an intuitive way. 85: 86: e.g. An {{code}}o.o.o.smf.SmfService{{/code}} is usually constructed using an 87: {{code}}o.o.o.scf.Service{{/code}}. An {{code}}o.o.o.smf.SmfInstance{{/code}} can be created using 88: an {{code}}o.o.o.scf.Instance{{/code}}, or by calling {{code}}SmfService.instances(){{/code}}. 89: 90: Error handling in {{code}}o.o.o.smf{{/code}} classes is in some places worse than in 91: {{code}}o.o.o.scf{{/code}}, as we simply pass through the already confusing underlying 92: errors. In other places it is better, since we have high-level logic 93: for which we can use the sensible standard Java exceptions. Your 94: mileage will vary. 95: 96: === Example 97: 98: Here’s a simple example program which connects to the repository, and 99: dumps out a list of services and their states: 100: 101: import org.opensolaris.os.scf.\*; 102: import org.opensolaris.os.smf.\*; 103: public class SvcList 104: { 105: public static void main(String[] args) 106: { 107: Handle h = new Handle(); 108: try { 109: h.bind(); 110: Scope s = h.scope(Scope.SCF~_SCOPE~_LOCAL()); 111: for (Service svc : s.services()) { 112: SmfService smfsvc = new SmfService(svc); 113: for (SmfInstance i : smfsvc.instances()) 114: System.out.printf("%-16s%s\n", 115: i.getState().toString(), 116: i.toString()); 117: } 118: } catch (ScfException e) { 119: System.err.println("Ouch."); 120: return; 121: } 122: } 123: } 124: 125: All that is necessary to build and run this, or any other 126: {{code}}o.o.o.scf{{/code}}/{{code}}smf{{/code}} consumer, is to point your classpath at 127: {{code}}/opt/OSOL0vpanels/lib/java/scf.jar{{/code}}. There is no need to build or 128: even extract the source, and no need to set your {{code}}LD~_LIBRARY~_PATH{{/code}} to 129: find the native library. Even if you move the directory tree around, 130: the native library should be found as long as {{code}}scf.jar{{/code}} and 131: {{code}}libscf_jni.so.1{{/code}} have the same relative locations.
Search
Collectives
Community Group
Academic and Research
Accessibility
Advocacy
Appliances
Approachability
Architecture Process and Tools
BrandZ
Chinese Users
Community Advisory Board
Databases
Desktop
Device Drivers
Distribution
Documentation
DTrace
Emerging Platforms
Fault Management
Games on OpenSolaris
HA Clusters
HPC Developer
Installation and Packaging
Internationalization and Localization
Laptop
Logical Domains
Modular Debugger (MDB)
Networking
NFS
Observability
OpenSolaris Governing Board (OGB)
OpenSolaris Printing
OS/Net (ON)
Performance
Power Management
PowerPC
Security
Service Management Facility (smf(5))
Software Porters
Solaris Volume Manager
Storage
Systems Administration Community Group
Testing
Tools Home
Unix File Systems (UFS)
Website Community
X Window System
Xen
ZFS
Zones
Project
ADSL Modem Enhancement
ARC Process Definition
ARM Platform Port
Automatic Data Migration
BIND Update
Bluetooth Stack & Drivers
Brocade FC HBA - Initiator
Brocade FC HBA - Target
Brussels - unified network link configuration
Caiman, Solaris Install Revisited
Celeste
Český portál
Chime Visualization Tool for DTrace
CIFS client for Solaris
CIFS Server
Clearview: Network Interface Coherence
Cluster Agent: Informix Dynamic Server
Cluster Agent: OpenSolaris Container
Cluster Agent: OpenSolaris xVM
Cluster Agent: Oracle E-Business Suite
Cluster agent: PostgreSQL
Cluster Agent: Samba
Cluster Agent: Tomcat
CMT
Coarse Data Flow Parallelism
Colorado: Open HA Cluster on OpenSolaris
Command Assistant
Common Array Manager
Companion - /opt/sfw: Free and Open Source software
COMSTAR: Common Multiprotocol SCSI Target
Content
Contest
CPU Observability
Credentials Process Groups
Crossbow: Network Virtualization and Resource Control
Crypto KMS Agent Toolkit
Cryptographic Framework
Data Migration Manager
Data Tethers
Deutsches Portal
Device Detection Tool
Device Driver Utility
Device Manager
Device Mapper
Direct Rendering Infrastructure & 3D drivers
DTrace Guide
Duckwater: Simplified name services management
Easy Tools
Emancipation
Emulex Fibre Channel Device Driver
Emulex Advanced Ethernet Device Driver
Enable/Enhance Solaris support for Intel Platform
Enhance the support of USB webcams
Enhanced SMF Profiles
Enhancements for AMD-based Platforms
Erlang DTrace Integration
Ethernet bridge module for Solaris
Evaluate Conary
Events Registry
Ext3 file system support
F/OSS Package Base
Facilitation
Fibre Channel over Ethernet
Fine Grained Access Policy (FGAP)
Fingerprint Authentication
Flexible Mandatory Access Control
Forensic Tools
Fully Open X Project
Fuse on Solaris
gcore
Generic Machine Check Architecture Improvements
Google SOC
HA-JBoss
HA-MySQL
Hadoop Live CD
Hitachi
HoneyComb Fixed Content Storage
HPC Stack
Image Packaging System
Improved Performance MIB
Indiana
Innovation Awards
Input Method
Intel Graphics
Internet Key Exchange, version 2
Interrupt Resource Management
IP Datapath Refactoring
IP over Infiniband
IPsec Tunnel Reform
iSCSI Extensions for Remote DMA (iSER)
iSNS Server
JeOS - Just enough Operating System
JKstat - a java binding for libkstat
Journaled File System (JFS)
K Desktop Environment
Kerberos
Kernel Sockets
Kernel SSL Enhancements
Key Management Framework
Korn Shell 93 integration/migration project
Labeled IPsec
LatencyTOP
Layer 2 Filtering
LDoms Manager
Lending
libMicro - portable microbenchmarks
Link Layer Discovery
Live Media: Technologies for distributions running from CD and other media
Locale Data
lofi compression and cryptography support
lx64 brand
Media Management System
Mega_sas
Mexico
MilaX minimal Live Distribution
MIPS Platform Port
Mozilla DTrace
MRSL.NONsharedDevice
Multi-lingual Glossary
Multi-pathing software (MPxIO)
Multiple disk sector size support
Multiple DOI
Muskoka: An open repository for OpenSolaris technical content
Navigator
Nemo: A Framework for High-Performance Networking
Network Auto-Magic
Network Data Management Protocol
Network MIBs
Network Storage
Network Time Protocol (NTP)
Nevada Globalization
New Design of 4over6 Mechanism Based on OpenSolaris
NFS RDMA transport update and performance analysis
NFS Server in non-Global Zones
NFS version 4.1 pNFS
NFSv4 namespace extensions
Nightingale: Port Songbird to OpenSolaris
NPort ID Virtualization (NPIV)
NUMA
Object Storage Device (OSD) support for Solaris
OHACGE Script Based Plug-in
ON/Nevada (ONNV) Project
Open Development Infrastructure
Open HA Cluster Utilities
Open Sound System
OpenGrok
OpenPegasus CIM Server
OpenRTI
OpenSolaris Busybox
OpenSolaris Desktop
OpenSolaris Hispano
OpenSolaris Security Audit
OpenSolaris support for the QEMU processor emulator: host and guest
PEF: Packet Event Framework
Performance Wrappers
Pkgfactory
Polski Portal
Portail Francophone
Portal Brasil
Portals
Power Management Usability Interfaces
Presto: Automatic Printing Configuration
Printable Many Page Solaris Manuals
Promise SuperTrak RAID HBA Driver
QLogic Converged Network Adapter GLDv3 NIC Driver
Quagga Routing Protocol Suite Integration
RAID Configuration Utility
RBridge (IETF TRILL) support
RDMA Offload Framework
Reno: Login Process Enhancements for Interop
Resource Management
s10brand
SAM/QFS
SCM Migration Project
SCSI RDMA Protocol
SDcard Drivers
Sensor Abstraction Layer
Session Initiation Protocol
SFW
Shell: bourne shell, korn shell, C shell, etc.
Sierra: Intel WiFi Chipsets Support
Simple Panels
SM-HBA Based SAS HBA Management
SMF Documentation
Solaris iSCSI Target
Solaris PowerPC Port
SourceJuicer
Sparks: name service switch/nscd enhancements
Squashfs
Star integration/migration project
Starfish
Starter Kit
Storage Power Management
Sun Security Toolkit
Sun StorageTek Availability Suite
Support for OpenFabrics User Verbs / API on OpenSolaris OS
Support gcc4/GCCfss in Solaris
Suspend/Resume
SVR4 Packaging
Systemz
Tamarack: Removable Media Enhancements in Solaris
Tesla: OpenSolaris Enhanced Power Management
Test Development
Tickless Kernel Architecture
TIPC
Trademarks
Trusted networking interface policy database for Trusted Extensions
Trusted Platform Module support
Use Case
Validated Execution Project
Virtual Console
Virtual Network Machines
Visual Panels
Visualization for HPC
Volo
VRRP: Virtual Router Redundancy Protocol Implementation
VSCAN service
Web Stack
Website
Winchester: Schema mapping and ID mapping for AD Interoperability
Wireless USB Support
Wireless Wide Area Network
X Consolidation
x86 Generic FMA Topology Enumerator
Xen Gate
Xfce: A lightweight desktop environment
ZFS Boot and Install
ZFS on disk encryption support
Zone Manager
Zone Statistics
Русский портал
البوابة العربية
भारतीय पोर्टल
中国门户
日本ポータル
한국 포탈
User Group
Adelaide
Argentina
Arizona
Atlanta
Baltimore-Washington
Bangalore
Bangkok
Bangladesh
Beijing
Bélem
Berlin
Bhimavaram
Bloomington
Campus Ambassadors
Capital Region
Cardiff
Charlotte
Chengdu
Chennai
Chihuahua
Chile
Cleveland
Colombia
Columbus
Connecticut
Cracow
Czech
Dallas/Ft. Worth
Danish
Delaware
Edinburgh
Egypt
Finland
Florida
Front Range
FuZhou
Great Lakes
Greece
Hangzhou
Hawaii
HeFei
Houston
Hyderabad
Indonesia
Irish
Israel
Italian
Jinan
Kabul
Kansas City
Latvia
London
Madurai
Manchester
Mato Grosso
Melbourne
Minas Gerais
Minnesota
Montreal
Moscow
Mumbai
Munich
NEA
Netherlands
New England
New York City
New Zealand
NIT Hamirpur
Noroeste
Oklahoma City
Osnabrück
Peru
Philadelphia
Piaski
Pittsburgh
Porto Alegre
Puget Sound
Pune
Queensland
Research Triangle Park
Romania
Russia
San Antonio
San Diego
San Francisco
São Paulo
Scottish
Serbia
Shanghai
Shenzhen
Silicon Valley
Singapore
Slovak
South African
Southern Connecticut
St. Louis
Sweden
Switzerland
Sydney
Szczecin
Taiwan
Tecum
Thames Valley
Tokyo
Toronto
Trondheim
Tulsa
Turkey
Ukraine
University of Melbourne
Vale do Paraíba
Vancouver
Venezuela
Welsh - Cymru
Wisconsin
Xi'an
Subsites
Code Reviews
Code Repositories
Package Search
Bugster
Bugzilla
Test Machines
Planet
Mailing Lists
Elections & Polls
ARC Case Logs
Source Juicer
Package Factory
User Authentication
Project vpanels Pages
Documentation
Visual Panels Documentation for 2008.05
OpenSolaris Development
Development
FAQs
Files
Firewall framework
Installation
The Java SCF interfaces
The JMX Agent
Screenshots
Screenshots (2008.05)
Template extensions
The Visual Panels demo