Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
nfs4j
Commits
2e941e22
Commit
2e941e22
authored
May 28, 2010
by
Tigran Mkrtchyan
☕
Browse files
rpc: start RPC services with Spring IoC
Acked-By: Paul Millar
parent
22ed74c1
Changes
6
Hide whitespace changes
Inline
Side-by-side
oncrpcsvc.xml
0 → 100644
View file @
2e941e22
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
>
<bean
id=
"dataSource"
class=
"com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method=
"close"
>
<property
name=
"user"
value=
"postgres"
/>
<property
name=
"password"
value=
""
/>
<property
name=
"driverClass"
value=
"org.postgresql.Driver"
/>
<property
name=
"jdbcUrl"
value=
"jdbc:postgresql://localhost/chimera?prepareThreshold=3"
/>
</bean>
<!--
NFSv4.1 pNFS Data Server manager
-->
<bean
id=
"device-manager"
class=
"org.dcache.chimera.nfs.v4.DeviceManager"
>
<description>
Device manager
</description>
</bean>
<!--
FileSystem engine. Currently only Chimera is supported
-->
<bean
id=
"fileSystem"
class=
"org.dcache.chimera.JdbcFs"
>
<description>
Chimera Filesystem
</description>
<constructor-arg
ref=
"dataSource"
/>
<constructor-arg
value=
"PgSQL"
/>
</bean>
<bean
id=
"export"
class=
"org.dcache.chimera.nfs.ExportFile"
>
<description>
Export file
</description>
<constructor-arg>
<bean
class=
"java.io.File"
>
<constructor-arg
value=
"/etc/exports"
/>
</bean>
</constructor-arg>
</bean>
<!--
NFSv4.1 Operation factory
-->
<bean
id=
"mds-factory"
class=
"org.dcache.chimera.nfs.v4.MDSOperationFactory"
>
<description>
MDS operation factory
</description>
</bean>
<!--
NFSv4.1 Operation factory
-->
<bean
id=
"ds-factory"
class=
"org.dcache.chimera.nfs.v4.mover.DSOperationFactory"
>
<description>
DS operation factory
</description>
</bean>
<bean
id=
"acl-handler"
class=
"org.dcache.chimera.posix.UnixPermissionHandler"
factory-method=
"getInstance"
/>
<!--
NFSv4.1 MDS
-->
<bean
id=
"mds"
class=
"org.dcache.chimera.nfs.v4.NFSServerV41"
>
<description>
NFSv4.1 MDS server
</description>
<constructor-arg
ref=
"mds-factory"
/>
<constructor-arg
ref=
"device-manager"
/>
<constructor-arg
ref=
"acl-handler"
/>
<constructor-arg
ref=
"fileSystem"
/>
<constructor-arg
ref=
"export"
/>
</bean>
<!--
NFSv4.1 DS
-->
<bean
id=
"ds"
class=
"org.dcache.chimera.nfs.v4.NFSServerV41"
>
<description>
NFSv4.1 DS server
</description>
<constructor-arg
index=
"0"
ref=
"ds-factory"
/>
<constructor-arg
index=
"1"
ref=
"device-manager"
/>
<constructor-arg
index=
"2"
ref=
"acl-handler"
/>
<constructor-arg
index=
"3"
ref=
"fileSystem"
/>
<constructor-arg
index=
"4"
><null/></constructor-arg>
</bean>
<!--
MOUNTD server
-->
<bean
id=
"mountd"
class=
"org.dcache.chimera.nfs.v3.MountServer"
>
<description>
Mountd seriver
</description>
<constructor-arg
ref=
"export"
/>
<constructor-arg
ref=
"fileSystem"
/>
</bean>
<!--
Embeded RPCBIND.
It will autodetect if there a system one already enabled.
-->
<bean
id=
"rpcbind"
class=
"org.dcache.xdr.portmap.OncRpcEmbeddedPortmap"
/>
<!-- NFSv4 programm -->
<bean
id=
"nfsv4-programm"
class=
"org.dcache.xdr.OncRpcProgram"
>
<description>
NFSv4.1 programm number
</description>
<constructor-arg
index=
"0"
value=
"100003"
/>
<constructor-arg
index=
"1"
value=
"4"
/>
</bean>
<!-- NFSv3 programm -->
<bean
id=
"nfsv3-programm"
class=
"org.dcache.xdr.OncRpcProgram"
>
<description>
NFSv3 programm number
</description>
<constructor-arg
index=
"0"
value=
"100003"
/>
<constructor-arg
index=
"1"
value=
"3"
/>
</bean>
<!-- mount programm -->
<bean
id=
"mount-programm"
class=
"org.dcache.xdr.OncRpcProgram"
>
<description>
Mount programm number
</description>
<constructor-arg
index=
"0"
value=
"100005"
/>
<constructor-arg
index=
"1"
value=
"3"
/>
</bean>
<!--
NFSv3
-->
<bean
id=
"nfs3"
class=
"org.dcache.chimera.nfs.v3.NfsServerV3"
>
<description>
NFSv3 server
</description>
<constructor-arg
ref=
"fileSystem"
/>
<constructor-arg
ref=
"export"
/>
</bean>
<!--
ONC RPC service
-->
<bean
id=
"oncrpcsvc"
class=
"org.dcache.xdr.OncRpcSvc"
destroy-method=
"stop"
depends-on=
"rpcbind,oncrpcsvc-ds"
>
<description>
Onc RPC service for MDS
</description>
<constructor-arg
type=
"int"
value=
"2049"
/>
<property
name=
"programs"
>
<map>
<entry
key-ref=
"nfsv4-programm"
value-ref=
"mds"
/>
<entry
key-ref=
"nfsv3-programm"
value-ref=
"nfs3"
/>
<entry
key-ref=
"mount-programm"
value-ref=
"mountd"
/>
</map>
</property>
</bean>
<!--
ONC RPC service for MDS
-->
<bean
id=
"oncrpcsvc-ds"
class=
"org.dcache.xdr.OncRpcSvc"
destroy-method=
"stop"
>
<description>
Onc RPC service FOR DS
</description>
<constructor-arg
type=
"int"
value=
"2052"
/>
<constructor-arg
type=
"boolean"
value=
"false"
/>
<property
name=
"programs"
>
<map>
<entry
key-ref=
"nfsv4-programm"
value-ref=
"ds"
/>
</map>
</property>
</bean>
</beans>
pom.xml
View file @
2e941e22
...
...
@@ -51,6 +51,23 @@
<target>
1.6
</target>
</configuration>
</plugin>
<!--
start java app
-->
<plugin>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
exec-maven-plugin
</artifactId>
<executions>
<execution>
<goals>
<goal>
java
</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>
org.dcache.xdr.SpringRunner
</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-jar-plugin
</artifactId>
...
...
@@ -89,6 +106,11 @@
<descriptorRef>
jar-with-dependencies
</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>
org.dcache.xdr.SpringRunner
</mainClass>
<packageName>
org.dcache.chimera.nfs
</packageName>
<addExtensions/>
</manifest>
<manifestEntries>
<mode>
development
</mode>
<Implementation-Build>
${buildNumber}
</Implementation-Build>
...
...
@@ -180,6 +202,11 @@
<artifactId>
jline
</artifactId>
<version>
0.9.94
</version>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring
</artifactId>
<version>
2.5.6
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
...
...
@@ -213,7 +240,7 @@
<dependency>
<groupId>
org.dcache.chimera
</groupId>
<artifactId>
chimera-core
</artifactId>
<version>
1.9.5
</version>
<version>
0.0.9
</version>
</dependency>
</dependencies>
...
...
src/org/dcache/chimera/nfs/v3/Main.java
deleted
100644 → 0
View file @
22ed74c1
/*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program (see the file COPYING.LIB for more
* details); if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package
org.dcache.chimera.nfs.v3
;
import
java.io.File
;
import
java.net.InetAddress
;
import
org.acplt.oncrpc.OncRpcPortmapClient
;
import
org.acplt.oncrpc.OncRpcProtocols
;
import
org.dcache.chimera.FileSystemProvider
;
import
org.dcache.chimera.JdbcFs
;
import
org.dcache.chimera.XMLconfig
;
import
org.dcache.chimera.nfs.ExportFile
;
import
org.dcache.chimera.nfs.v3.xdr.mount_prot
;
import
org.dcache.chimera.nfs.v3.xdr.nfs3_prot
;
import
org.dcache.xdr.OncRpcSvc
;
import
org.dcache.xdr.OncRpcProgram
;
import
org.dcache.xdr.portmap.OncRpcEmbeddedPortmap
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
Main
{
private
final
static
Logger
_log
=
LoggerFactory
.
getLogger
(
Main
.
class
);
static
final
int
DEFAULT_PORT
=
2049
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
.
length
!=
1
)
{
_log
.
error
(
"Usage: Main <config>"
);
System
.
exit
(
1
);
}
XMLconfig
config
=
new
XMLconfig
(
new
File
(
args
[
0
]));
FileSystemProvider
fs
=
new
JdbcFs
(
config
);
_log
.
info
(
"starting NFSv3 on: {}"
,
DEFAULT_PORT
);
new
OncRpcEmbeddedPortmap
(
2000
);
OncRpcPortmapClient
portmap
=
new
OncRpcPortmapClient
(
InetAddress
.
getByName
(
"127.0.0.1"
));
portmap
.
getOncRpcClient
().
setTimeout
(
2000
);
if
(!
portmap
.
setPort
(
mount_prot
.
MOUNT_PROGRAM
,
mount_prot
.
MOUNT_V3
,
OncRpcProtocols
.
ONCRPC_TCP
,
2049
))
{
_log
.
error
(
"Failed to register mountv1 service within portmap."
);
}
if
(!
portmap
.
setPort
(
mount_prot
.
MOUNT_PROGRAM
,
mount_prot
.
MOUNT_V3
,
OncRpcProtocols
.
ONCRPC_UDP
,
2049
))
{
_log
.
error
(
"Failed to register mountv1 service within portmap."
);
}
if
(!
portmap
.
setPort
(
mount_prot
.
MOUNT_PROGRAM
,
mount_prot
.
MOUNT_V1
,
OncRpcProtocols
.
ONCRPC_TCP
,
2049
))
{
_log
.
error
(
"Failed to register mountv3 service within portmap."
);
}
if
(!
portmap
.
setPort
(
mount_prot
.
MOUNT_PROGRAM
,
mount_prot
.
MOUNT_V1
,
OncRpcProtocols
.
ONCRPC_UDP
,
2049
))
{
_log
.
error
(
"Failed to register mountv3 service within portmap."
);
}
if
(!
portmap
.
setPort
(
nfs3_prot
.
NFS_PROGRAM
,
nfs3_prot
.
NFS_V3
,
OncRpcProtocols
.
ONCRPC_TCP
,
2049
))
{
_log
.
error
(
"Failed to register NFSv3 service within portmap."
);
}
if
(!
portmap
.
setPort
(
nfs3_prot
.
NFS_PROGRAM
,
nfs3_prot
.
NFS_V3
,
OncRpcProtocols
.
ONCRPC_UDP
,
2049
))
{
_log
.
error
(
"Failed to register NFSv3 service within portmap."
);
}
ExportFile
exports
=
new
ExportFile
(
new
File
(
"/etc/exports"
));
MountServer
ms
=
new
MountServer
(
exports
,
fs
);
NfsServerV3
nfs3
=
new
NfsServerV3
(
exports
,
fs
);
OncRpcSvc
service
=
new
OncRpcSvc
(
DEFAULT_PORT
);
service
.
register
(
new
OncRpcProgram
(
nfs3_prot
.
NFS_PROGRAM
,
nfs3_prot
.
NFS_V3
),
nfs3
);
service
.
register
(
new
OncRpcProgram
(
mount_prot
.
MOUNT_PROGRAM
,
mount_prot
.
MOUNT_V3
),
ms
);
service
.
start
();
}
}
src/org/dcache/chimera/nfs/v4/Main.java
deleted
100644 → 0
View file @
22ed74c1
/*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program (see the file COPYING.LIB for more
* details); if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package
org.dcache.chimera.nfs.v4
;
import
org.acplt.oncrpc.OncRpcPortmapClient
;
import
org.acplt.oncrpc.OncRpcProtocols
;
import
org.dcache.chimera.FileSystemProvider
;
import
org.dcache.chimera.JdbcFs
;
import
org.dcache.chimera.XMLconfig
;
import
org.dcache.chimera.nfs.ExportFile
;
import
org.dcache.chimera.nfs.v3.MountServer
;
import
org.dcache.chimera.nfs.v3.xdr.mount_prot
;
import
org.dcache.chimera.nfs.v4.mover.DSOperationFactory
;
import
org.dcache.chimera.nfs.v4.xdr.nfs4_prot
;
import
org.dcache.chimera.posix.UnixPermissionHandler
;
import
org.dcache.xdr.OncRpcProgram
;
import
org.dcache.xdr.OncRpcSvc
;
import
org.dcache.xdr.portmap.OncRpcEmbeddedPortmap
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.File
;
import
java.net.InetAddress
;
public
class
Main
{
private
final
static
Logger
_log
=
LoggerFactory
.
getLogger
(
Main
.
class
);
static
final
int
DEFAULT_PORT_MDS
=
2049
;
static
final
int
DEFAULT_PORT_DS
=
2052
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
.
length
!=
2
)
{
System
.
err
.
println
(
"Usage: Main <chimera-config> <mds|ds>"
);
System
.
exit
(
1
);
}
boolean
mds
=
args
[
1
].
equals
(
"mds"
);
XMLconfig
config
=
new
XMLconfig
(
new
File
(
args
[
0
]));
FileSystemProvider
fs
=
new
JdbcFs
(
config
);
OncRpcSvc
service
;
int
port
;
if
(
mds
)
{
port
=
DEFAULT_PORT_MDS
;
service
=
new
OncRpcSvc
(
port
);
_log
.
info
(
"starting MDS on: {}"
,
port
);
new
OncRpcEmbeddedPortmap
(
2000
);
OncRpcPortmapClient
portmap
=
new
OncRpcPortmapClient
(
InetAddress
.
getByName
(
"127.0.0.1"
));
portmap
.
getOncRpcClient
().
setTimeout
(
2000
);
if
(
!
portmap
.
setPort
(
mount_prot
.
MOUNT_PROGRAM
,
mount_prot
.
MOUNT_V3
,
OncRpcProtocols
.
ONCRPC_TCP
,
2049
)
)
{
_log
.
error
(
"Failed to register mountv1 service within portmap."
);
}
if
(!
portmap
.
setPort
(
mount_prot
.
MOUNT_PROGRAM
,
mount_prot
.
MOUNT_V3
,
OncRpcProtocols
.
ONCRPC_UDP
,
2049
))
{
_log
.
error
(
"Failed to register mountv1 service within portmap."
);
}
if
(!
portmap
.
setPort
(
mount_prot
.
MOUNT_PROGRAM
,
mount_prot
.
MOUNT_V1
,
OncRpcProtocols
.
ONCRPC_TCP
,
2049
))
{
_log
.
error
(
"Failed to register mountv3 service within portmap."
);
}
if
(!
portmap
.
setPort
(
mount_prot
.
MOUNT_PROGRAM
,
mount_prot
.
MOUNT_V1
,
OncRpcProtocols
.
ONCRPC_UDP
,
2049
))
{
_log
.
error
(
"Failed to register mountv3 service within portmap."
);
}
if
(
!
portmap
.
setPort
(
nfs4_prot
.
NFS4_PROGRAM
,
nfs4_prot
.
NFS_V4
,
OncRpcProtocols
.
ONCRPC_TCP
,
2049
)
)
{
_log
.
error
(
"Failed to register NFSv4 service within portmap."
);
}
ExportFile
exports
=
new
ExportFile
(
new
File
(
"/etc/exports"
));
MountServer
ms
=
new
MountServer
(
exports
,
fs
);
NFSServerV41
nfs4
=
new
NFSServerV41
(
new
MDSOperationFactory
(),
new
DeviceManager
(),
UnixPermissionHandler
.
getInstance
(),
fs
,
exports
);
service
.
register
(
new
OncRpcProgram
(
nfs4_prot
.
NFS4_PROGRAM
,
nfs4_prot
.
NFS_V4
),
nfs4
);
service
.
register
(
new
OncRpcProgram
(
mount_prot
.
MOUNT_PROGRAM
,
mount_prot
.
MOUNT_V3
),
ms
);
}
else
{
port
=
DEFAULT_PORT_DS
;
service
=
new
OncRpcSvc
(
port
);
_log
.
info
(
"starting DS on: {}"
,
port
);
NFSServerV41
ds
=
new
NFSServerV41
(
new
DSOperationFactory
(),
new
DeviceManager
(),
UnixPermissionHandler
.
getInstance
(),
fs
,
null
);
service
.
register
(
new
OncRpcProgram
(
nfs4_prot
.
NFS4_PROGRAM
,
nfs4_prot
.
NFS_V4
),
ds
);
}
service
.
start
();
}
}
src/org/dcache/xdr/OncRpcSvc.java
View file @
2e941e22
...
...
@@ -238,6 +238,14 @@ public class OncRpcSvc {
}
}
/**
* Add programs to existing services.
* @param services
*/
public
void
setPrograms
(
Map
<
OncRpcProgram
,
RpcDispatchable
>
services
)
{
_programs
.
putAll
(
services
);
}
/**
* Register a new PRC service. Existing registration will be overwritten.
*
...
...
src/org/dcache/xdr/SpringRunner.java
0 → 100644
View file @
2e941e22
/*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program (see the file COPYING.LIB for more
* details); if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package
org.dcache.xdr
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
org.springframework.beans.factory.BeanFactory
;
import
org.springframework.beans.factory.xml.XmlBeanFactory
;
import
org.springframework.core.io.FileSystemResource
;
public
class
SpringRunner
{
private
SpringRunner
()
{
// this class it used only to bootstrap the Spring IoC
}
public
static
void
main
(
String
[]
args
)
throws
FileNotFoundException
,
IOException
{
if
(
args
.
length
!=
1
)
{
System
.
err
.
println
(
"Usage: SpringRunner <config>"
);
System
.
exit
(
1
);
}
BeanFactory
factory
=
new
XmlBeanFactory
(
new
FileSystemResource
(
args
[
0
]));
OncRpcSvc
service
=
(
OncRpcSvc
)
factory
.
getBean
(
"oncrpcsvc"
);
service
.
start
();
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment