1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 * 26 * ident "%Z%%M% %I% %E% SMI" 27 */ 28 29 package com.sun.solaris.service.pools; 30 31 /** 32 * A thin layer over the libpool(3LIB) interface so that Java can be 33 * used to manipulate resource pools. For more information on this 34 * facility refer to the manpage and the developer documentation. 35 * 36 * Most of the functionality in this class is not intended to be 37 * exposed to users of the package. The other classes in the package 38 * provide appropriate Java abstractions for using this functionality. 39 * 40 * Refer to the package documentation and the documentation of the 41 * other publicly visible classes for more details. 42 */ 43 public class PoolInternal { 44 static { 45 System.loadLibrary("jpool"); 46 PoolInternal.init(); 47 } 48 49 final static native void init(); 50 final static native long pool_version(long ver); 51 final static native int get_POX_NATIVE(); 52 final static native int get_POX_TEXT(); 53 final static native int get_POC_INVAL(); 54 final static native int get_POC_UINT(); 55 final static native int get_POC_INT(); 56 final static native int get_POC_DOUBLE(); 57 final static native int get_POC_BOOL(); 58 final static native int get_POC_STRING(); 59 final static native int get_POV_NONE(); 60 final static native int get_POV_LOOSE(); 61 final static native int get_POV_STRICT(); 62 final static native int get_POV_RUNTIME(); 63 final static native int get_POF_INVALID(); 64 final static native int get_POF_VALID(); 65 final static native int get_POF_DESTROY(); 66 public final static native int pool_error(); 67 public final static native String pool_strerror(int error); 68 public final static native String pool_strerror_sys(); 69 public final static native int pool_resource_type_list(long types, 70 long numtypes); 71 public final static native int pool_get_status(); 72 public final static native int pool_set_status(int state); 73 final static native long pool_conf_alloc(); 74 final static native void pool_conf_free(long conf); 75 final static native int pool_conf_status(long conf); 76 final static native int pool_conf_close(long conf); 77 final static native int pool_conf_remove(long conf); 78 final static native int pool_conf_open(long conf, String location, 79 int oflags); 80 final static native int pool_conf_rollback(long conf); 81 final static native int pool_conf_commit(long conf, int active); 82 final static native int pool_conf_export(long conf, String location, 83 int fmt); 84 final static native int pool_conf_validate(long conf, int level); 85 final static native int pool_conf_update(long conf); 86 final static native long pool_get_pool(long conf, String name); 87 final static native java.util.List pool_query_pools(long conf, 88 java.util.List props); 89 final static native long pool_get_resource(long conf, String type, 90 String name); 91 final static native java.util.List pool_query_resources(long conf, 92 java.util.List props); 93 final static native java.util.List pool_query_components(long conf, 94 java.util.List props); 95 final static native String pool_conf_location(long conf); 96 final static native String pool_conf_info(long conf, int deep); 97 final static native long pool_resource_create(long conf, 98 String type, String name); 99 final static native int pool_resource_destroy(long conf, long res); 100 final static native int pool_resource_transfer(long conf, 101 long src, long tgt, long size); 102 final static native int pool_resource_xtransfer(long conf, 103 long src, long tgt, java.util.List components); 104 final static native java.util.List pool_query_resource_components( 105 long conf, long res, java.util.List props); 106 final static native String pool_resource_info(long conf, long res, 107 int deep); 108 final static native long pool_create(long conf, String name); 109 final static native int pool_destroy(long conf, long pool); 110 final static native int pool_associate(long conf, long pool, 111 long res); 112 final static native int pool_dissociate(long conf, long pool, 113 long res); 114 final static native String pool_info(long conf, long pool, int deep); 115 final static native java.util.List pool_query_pool_resources( 116 long conf, long pool, java.util.List props); 117 final static native long pool_get_owning_resource(long conf, 118 long comp); 119 final static native String pool_component_info(long conf, 120 long comp, int deep); 121 final static native int pool_get_property(long conf, long elem, 122 String name, long val); 123 final static native int pool_put_property(long conf, long elem, 124 String name, long val); 125 final static native int pool_rm_property(long conf, long elem, 126 String name); 127 final static native int pool_walk_properties(long conf, long elem, 128 long user, long callback); 129 final static native long pool_conf_to_elem(long conf); 130 final static native long pool_to_elem(long conf, long pool); 131 final static native long pool_resource_to_elem(long conf, long res); 132 final static native long pool_component_to_elem(long conf, long comp); 133 final static native int pool_value_get_uint64(long pv, long result); 134 final static native int pool_value_get_int64(long pv, long result); 135 final static native int pool_value_get_double(long pv, long result); 136 final static native int pool_value_get_bool(long pv, long result); 137 final static native int pool_value_get_string(long pv, long result); 138 final static native int pool_value_get_type(long pv); 139 final static native void pool_value_set_uint64(long pv, long val); 140 final static native void pool_value_set_int64(long pv, long val); 141 final static native void pool_value_set_double(long pv, double val); 142 final static native void pool_value_set_bool(long pv, short val); 143 final static native int pool_value_set_string(long pv, String val); 144 final static native String pool_value_get_name(long pv); 145 final static native int pool_value_set_name(long pv, String val); 146 final static native long pool_value_alloc(); 147 final static native void pool_value_free(long pv); 148 public final static native String pool_static_location(); 149 public final static native String pool_dynamic_location(); 150 public final static native int pool_set_binding(String name, 151 int idtype, int id); 152 public final static native String pool_get_binding(int pid); 153 public final static native String pool_get_resource_binding( 154 String type, int pid); 155 final static native int pool_walk_pools(long conf, long user, 156 long callback); 157 final static native int pool_walk_resources(long conf, long pool, 158 long user, long callback); 159 final static native int pool_walk_components(long conf, long res, 160 long user, long callback); 161 /* 162 * enums and constants 163 */ 164 public final static int POOL_VER_CURRENT = 1; 165 public final static int POOL_VER_NONE = 0; 166 public final static int PO_TRUE = 1; 167 public final static int PO_FALSE = 0; 168 public final static int PO_SUCCESS = 0; 169 public final static int PO_FAIL = -1; 170 public final static int POE_OK = 0; 171 public final static int POE_BAD_PROP_TYPE = 1; 172 public final static int POE_INVALID_CONF = 2; 173 public final static int POE_NOTSUP = 3; 174 public final static int POE_INVALID_SEARCH = 4; 175 public final static int POE_BADPARAM = 5; 176 public final static int POE_PUTPROP = 6; 177 public final static int POE_DATASTORE = 7; 178 public final static int POE_SYSTEM = 8; 179 public final static int POE_ACCESS = 9; 180 public final static int PO_RDONLY = 0x0; 181 public final static int PO_RDWR = 0x1; 182 public final static int PO_CREAT = 0x2; 183 public final static int PO_DISCO = 0x4; 184 public final static int PO_UPDATE = 0x8; 185 public final static String POA_IMPORTANCE = "importance based"; 186 public final static String POA_SURPLUS_TO_DEFAULT = 187 "surplus to default"; 188 public final static int POU_SYSTEM = 0x1; 189 public final static int POU_POOL = 0x2; 190 public final static int POU_PSET = 0x4; 191 public final static int POU_CPU = 0x8; 192 public final static int POX_NATIVE = get_POX_NATIVE(); 193 public final static int POX_TEXT = get_POX_TEXT(); 194 public final static int POC_INVAL = get_POC_INVAL(); 195 public final static int POC_UINT = get_POC_UINT(); 196 public final static int POC_INT = get_POC_INT(); 197 public final static int POC_DOUBLE = get_POC_DOUBLE(); 198 public final static int POC_BOOL = get_POC_BOOL(); 199 public final static int POC_STRING = get_POC_STRING(); 200 public final static int POV_NONE = get_POV_NONE(); 201 public final static int POV_LOOSE = get_POV_LOOSE(); 202 public final static int POV_STRICT = get_POV_STRICT(); 203 public final static int POV_RUNTIME = get_POV_RUNTIME(); 204 public final static int POF_INVALID = get_POF_INVALID(); 205 public final static int POF_VALID = get_POF_VALID(); 206 public final static int POF_DESTROY = get_POF_DESTROY(); 207 } 208