我在实施身份验证插件时遇到了麻烦。在我的AuthPluginProcessor类的实例上引发NotSerializableException。禁用启用返回false的身份验证会使节点启动。
我想我错过了一些东西(我尝试将参数添加到authenticateNode但没有成功),下面是重现错误的最小代码。
AuthPluginProcessor:
public class AuthPluginProcessor implements IgnitePlugin, GridSecurityProcessor, Serializable
{
@Override
public SecurityContext authenticateNode(ClusterNode clusterNode, SecurityCredentials securityCredentials) throws IgniteCheckedException
{
return new SecurityContext() {
@Override
public SecuritySubject subject() { return null; }
@Override
public boolean taskOperationAllowed(String s, SecurityPermission securityPermission) { return true; }
@Override
public boolean cacheOperationAllowed(String s, SecurityPermission securityPermission) { return true; }
@Override
public boolean serviceOperationAllowed(String s, SecurityPermission securityPermission) { return true; }
@Override
public boolean systemOperationAllowed(SecurityPermission securityPermission) { return true; }
};
}
@Override
public boolean isGlobalNodeAuthentication() { return true; }
@Override
public boolean enabled() { return true; }
// others empty methods ...
}
以下是大部分日志文件:
[16:38:10,598][INFO][main][IgniteKernal] PID: 10152
[16:38:10,598][INFO][main][IgniteKernal] Language runtime: Java Platform API Specification ver. 1.8
[16:38:10,599][INFO][main][IgniteKernal] VM information: Java(TM) SE Runtime Environment 1.8.0_172-b11 Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 25.172-b11
[16:38:10,602][INFO][main][IgniteKernal] VM total memory: 0.96GB
[16:38:10,602][INFO][main][IgniteKernal] Remote Management [restart: on, REST: on, JMX (remote: on, port: 49186, auth: off, ssl: off)]
[16:38:10,603][INFO][main][IgniteKernal] Logger: JavaLogger [quiet=false, config=null]
[16:38:10,603][INFO][main][IgniteKernal] IGNITE_HOME=D:\db\Ignite2.4
[16:38:10,605][INFO][main][IgniteKernal] VM arguments: [-Xms1g, -Xmx1g, -XX:+AggressiveOpts, -XX:MaxMetaspaceSize=256m, -DIGNITE_QUIET=false, -DIGNITE_SUCCESS_FILE=D:\db\Ignite2.4\work\ignite_success_18756fda-d6de-4b6f-9ff2-5dc0bbe5f8b7, -Dcom.sun.management.jmxremote, -Dcom.sun.management.jmxremote.port=49186, -Dcom.sun.management.jmxremote.authenticate=false, -Dcom.sun.management.jmxremote.ssl=false, -DIGNITE_HOME=D:\db\Ignite2.4, -DIGNITE_PROG_NAME=ignite.bat]
[16:38:10,606][INFO][main][IgniteKernal] System cache's DataRegion size is configured to 40 MB. Use DataStorageConfiguration.systemCacheMemorySize property to change the setting.
[16:38:10,613][INFO][main][IgniteKernal] Configured caches [in 'sysMemPlc' dataRegion: ['ignite-sys-cache']]
[16:38:10,613][WARNING][main][IgniteKernal] Peer class loading is enabled (disable it in production for performance and deployment consistency reasons)
[16:38:10,617][WARNING][pub-#19][GridDiagnostic] This operating system has been tested less rigorously: Windows 10 10.0 amd64. Our team will appreciate the feedback if you experience any problems running ignite in this environment.
[16:38:10,620][INFO][main][IgniteKernal] 3-rd party licenses can be found at: D:\db\Ignite2.4\libs\licenses
[16:38:10,683][INFO][main][IgnitePluginProcessor] Configured plugins:
[16:38:10,684][INFO][main][IgnitePluginProcessor] ^-- AuthPlugin 0.1.0
[16:38:10,686][INFO][main][IgnitePluginProcessor] ^-- null
[16:38:10,686][INFO][main][IgnitePluginProcessor]
[16:38:10,725][INFO][main][TcpCommunicationSpi] Successfully bound communication NIO server to TCP port [port=47101, locHost=0.0.0.0/0.0.0.0, selectorsCnt=4, selectorSpins=0, pairedConn=false]
[16:38:11,230][WARNING][main][TcpCommunicationSpi] Message queue limit is set to 0 which may lead to potential OOMEs when running cache operations in FULL_ASYNC or PRIMARY_SYNC modes due to message queues growth on sender and receiver sides.
[16:38:11,242][WARNING][main][NoopCheckpointSpi] Checkpoints are disabled (to enable configure any GridCheckpointSpi implementation)
[16:38:11,263][WARNING][main][GridCollisionManager] Collision resolution is disabled (all jobs will be activated upon arrival).
[16:38:11,265][INFO][main][IgniteKernal] Security status [authentication=on, tls/ssl=off]
[16:38:11,314][INFO][main][TcpDiscoverySpi] Successfully bound to TCP port [port=47501, localHost=0.0.0.0/0.0.0.0, locNodeId=8acfdf1f-1371-443a-a6b1-38189fcee66f]
[16:38:12,331][INFO][main][PdsFoldersResolver] Unable to acquire lock to file [D:\db\Ignite2.4\work\db\node00-3413bf9c-56ea-4041-ae02-6967e6118354], reason: Failed to acquire file lock during 1 sec, (locked by [4c07699d-cb8f-4e20-9531-9154eb4e8a12][]): D:\db\Ignite2.4\work\db\node00-3413bf9c-56ea-4041-ae02-6967e6118354\lock
[16:38:12,364][INFO][main][PdsFoldersResolver] Successfully locked persistence storage folder [D:\db\Ignite2.4\work\db\node01-e607d470-4b11-42c1-b054-2a60a5ddaa02]
[16:38:12,364][INFO][main][PdsFoldersResolver] Consistent ID used for local node is [e607d470-4b11-42c1-b054-2a60a5ddaa02] according to persistence data storage folders
[16:38:12,365][INFO][main][CacheObjectBinaryProcessorImpl] Resolved directory for serialized binary metadata: D:\db\Ignite2.4\work\binary_meta\node01-e607d470-4b11-42c1-b054-2a60a5ddaa02
[16:38:12,530][INFO][main][FilePageStoreManager] Resolved page store work directory: D:\db\Ignite2.4\work\db\node01-e607d470-4b11-42c1-b054-2a60a5ddaa02
[16:38:12,531][INFO][main][FileWriteAheadLogManager] Resolved write ahead log work directory: D:\db\Ignite2.4\work\db\wal\node01-e607d470-4b11-42c1-b054-2a60a5ddaa02
[16:38:12,531][INFO][main][FileWriteAheadLogManager] Resolved write ahead log archive directory: D:\db\Ignite2.4\work\db\wal\archive\node01-e607d470-4b11-42c1-b054-2a60a5ddaa02
[16:38:12,543][INFO][main][FileWriteAheadLogManager] Started write-ahead log manager [mode=LOG_ONLY]
[16:38:12,552][INFO][main][GridCacheDatabaseSharedManager] Read checkpoint status [startMarker=null, endMarker=null]
[16:38:12,565][INFO][main][PageMemoryImpl] Started page memory [memoryAllocated=100,0 MiB, pages=24936, tableSize=1,4 MiB, checkpointBuffer=100,0 MiB]
[16:38:12,566][INFO][main][GridCacheDatabaseSharedManager] Checking memory state [lastValidPos=FileWALPointer [idx=0, fileOff=0, len=0], lastMarked=FileWALPointer [idx=0, fileOff=0, len=0], lastCheckpointId=00000000-0000-0000-0000-000000000000]
[16:38:12,572][INFO][main][GridCacheDatabaseSharedManager] Applying lost cache updates since last checkpoint record [lastMarked=FileWALPointer [idx=0, fileOff=0, len=0], lastCheckpointId=00000000-0000-0000-0000-000000000000]
[16:38:12,574][INFO][main][GridCacheDatabaseSharedManager] Finished applying WAL changes [updatesApplied=0, time=0ms]
[16:38:12,633][INFO][main][ClientListenerProcessor] Client connector processor has started on TCP port 10801
[16:38:12,665][INFO][main][GridTcpRestProtocol] Command protocol successfully started [name=TCP binary, host=0.0.0.0/0.0.0.0, port=11212]
[16:38:13,969][INFO][main][IgniteKernal] Non-loopback local IPs: 124.0.0.9, fe80:0:0:0:15be:bcfe:4ff6:1422%eth10, fe80:0:0:0:49ae:87cd:b8a4:a6bb%eth2, fe80:0:0:0:7943:2fb2:1da3:e69b%eth1, fe80:0:0:0:859b:b174:7412:4eb7%wlan1, fe80:0:0:0:d1fb:422:9dfa:aada%eth17, fe80:0:0:0:dd7d:8d79:7438:1db7%eth0, fe80:0:0:0:e593:8733:6979:aa7f%wlan0
[16:38:13,969][INFO][main][IgniteKernal] Enabled local MACs: 00090FFE0001, 00FF20F9E686, 025041000001, 184F32F210F1, 1A4F32F210F1, 54587804FD10, 54C6D294231E, 54CCB184D71B, 64006A8BA7BF
[16:38:13,995][SEVERE][main][IgniteKernal] Failed to start manager: GridManagerAdapter [enabled=true, name=o.a.i.i.managers.discovery.GridDiscoveryManager]
class org.apache.ignite.IgniteCheckedException: Failed to start SPI: TcpDiscoverySpi [addrRslvr=null, sockTimeout=5000, ackTimeout=5000, marsh=JdkMarshaller [clsFilter=org.apache.ignite.internal.IgniteKernal$5@3f390d63], reconCnt=10, reconDelay=2000, maxAckTimeout=600000, forceSrvMode=false, clientReconnectDisabled=false]
at org.apache.ignite.internal.managers.GridManagerAdapter.startSpi(GridManagerAdapter.java:300)
at org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.start(GridDiscoveryManager.java:892)
at org.apache.ignite.internal.IgniteKernal.startManager(IgniteKernal.java:1669)
at org.apache.ignite.internal.IgniteKernal.start(IgniteKernal.java:983)
at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.start0(IgnitionEx.java:1973)
at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.start(IgnitionEx.java:1716)
at org.apache.ignite.internal.IgnitionEx.start0(IgnitionEx.java:1144)
at org.apache.ignite.internal.IgnitionEx.startConfigurations(IgnitionEx.java:1062)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:948)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:847)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:717)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:686)
at org.apache.ignite.Ignition.start(Ignition.java:347)
at org.apache.ignite.startup.cmdline.CommandLineStartup.main(CommandLineStartup.java:302)
Caused by: class org.apache.ignite.spi.IgniteSpiException: Failed to authenticate local node (will shutdown local node).
at org.apache.ignite.spi.discovery.tcp.ServerImpl.localAuthentication(ServerImpl.java:991)
at org.apache.ignite.spi.discovery.tcp.ServerImpl.joinTopology(ServerImpl.java:862)
at org.apache.ignite.spi.discovery.tcp.ServerImpl.spiStart(ServerImpl.java:364)
at org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.spiStart(TcpDiscoverySpi.java:1930)
at org.apache.ignite.internal.managers.GridManagerAdapter.startSpi(GridManagerAdapter.java:297)
... 13 more
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to serialize object: test.ignite.AuthPluginProcessor$1@1af687fe
at org.apache.ignite.marshaller.jdk.JdkMarshaller.marshal0(JdkMarshaller.java:103)
at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.marshal(AbstractNodeNameAwareMarshaller.java:70)
at org.apache.ignite.marshaller.jdk.JdkMarshaller.marshal0(JdkMarshaller.java:117)
at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.marshal(AbstractNodeNameAwareMarshaller.java:58)
at org.apache.ignite.internal.util.IgniteUtils.marshal(IgniteUtils.java:9984)
at org.apache.ignite.spi.discovery.tcp.ServerImpl.localAuthentication(ServerImpl.java:985)
... 17 more
Caused by: java.io.NotSerializableException: test.ignite.AuthPluginProcessor$1
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
at org.apache.ignite.marshaller.jdk.JdkMarshaller.marshal0(JdkMarshaller.java:98)
... 22 more
以下是配置文件:
<bean abstract="true" id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<!-- Set to true to enable distributed class loading for examples, default is false. -->
<property name="peerClassLoadingEnabled" value="true"/>
<!-- Enable task execution events for examples. -->
<property name="includeEventTypes">
<list>
<!--Task execution events-->
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
<!--Cache events-->
<util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED"/>
</list>
</property>
<property name="pluginConfigurations">
<bean class="test.ignite.AuthPluginConfiguration"/>
</property>
<!--<property name="binaryConfiguration">
<bean class="org.apache.ignite.configuration.BinaryConfiguration">
<property name="compactFooter" value="false"/>
<property name="idMapper">
<bean class="org.apache.ignite.binary.BinaryBasicIdMapper">
<property name="lowerCase" value="true"/>
</bean>
</property>
</bean>
</property>-->
<!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<!--
Ignite provides several options for automatic discovery that can be used
instead os static IP based discovery. For information on all options refer
to our documentation: http://apacheignite.readme.io/docs/cluster-config
-->
<!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<value>124.0.0.127</value>
<value>124.0.0.125</value>
<value>124.0.0.9</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
<property name="dataStorageConfiguration">
<bean class="org.apache.ignite.configuration.DataStorageConfiguration">
<property name="defaultDataRegionConfiguration">
<bean class="org.apache.ignite.configuration.DataRegionConfiguration">
<property name="persistenceEnabled" value="true"/>
</bean>
</property>
</bean>
</property>
</bean>
答案 0 :(得分:2)
您的SecurityContext
可能无法实现Serializable
。
移至命名内部类=&gt;添加implements
。